Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider checking that there is only 1 primary (green) button #16

Open
frankieroberto opened this issue Sep 13, 2023 · 2 comments
Open
Labels
question Further information is requested

Comments

@frankieroberto
Copy link
Contributor

The Design System guidance for Buttons says:

Use a default button for the main call to action on a page.

Avoid using multiple default buttons on a single page. Having more than one main call to action reduces their impact, and makes it harder for users to know what to do next.

We could consider checking for this. However the guidance is only "avoid" rather than a hard rule, so it might need to be overridden.

@frankieroberto
Copy link
Contributor Author

Reposting this here from @joelanman:

Is having 2 green primary buttons on a page wrong?

Mostly, yes - I would include the multiple green error:

Avoid using multiple default buttons on a single page. Having more than one main call to action reduces their impact, and makes it harder for users to know what to do next.

The option to manually ignore with a flag sounds good, that means you know about the issue and made a conscious decision

Originally posted by @joelanman in #8 (comment)

@frankieroberto
Copy link
Contributor Author

Reposting this here from @frankieroberto:

Potentially we could output warning messages to the console log, unless you deliberately silence them. But they might still get ignored.

Another option would be to make the test fail unless you explicitly override it somehow. I did that for the disabled links, where you have to pass disabled: true. Could do something similar:

click_govuk_button("Continue",  ignore_other_primary_buttons: true)

...or some kind of global setting somewhere. Feels a bit icky though, somehow?

Another alternative would be just to make the helper more opinionated and always fail if there are 2 primary buttons. Teams could still fall back to using click_button if they really wanted to ignore the warning...

@frankieroberto frankieroberto added the question Further information is requested label Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant