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

Various fixes for html-validate (cookie banner buttons) #3116

Merged
merged 7 commits into from
Sep 20, 2023

Conversation

colinrotherham
Copy link
Contributor

@colinrotherham colinrotherham commented Sep 1, 2023

Follows on from #3115 to fix a few things spotted by html-validate

  1. Add button type="button" to Hide cookie message client-side buttons
  2. Add button type="submit" to Hide cookie message server-side buttons
  3. Remove button href="#" from Hide cookie message server-side buttons
  4. Remove button name and value from various client-side examples

To solve a gotcha I've hit in the past too, the Cookie banner and Cookies page form fields now match

E.g. The same server-side middleware could respond to form submissions from either the banner or page

Customised page template

I've updated the Customised page template cookie banner example to show server-side usage

Some client-side features from the guidance were missing such as:

  1. Message hidden by default users without JavaScript
  2. Additional confirmation messages for accept/reject
  3. Usage of role="alert" for confirmation messages

But we can add those missing features if we'd prefer it to show client-side usage instead

@colinrotherham colinrotherham added assurance cookie banner 🐛 bug Something isn't working the way it should (including incorrect wording in documentation) labels Sep 1, 2023
@netlify
Copy link

netlify bot commented Sep 1, 2023

You can preview this change here:

Name Link
🔨 Latest commit f72a9a8
🔍 Latest deploy log https://app.netlify.com/sites/govuk-design-system-preview/deploys/650ade62a256db0008140321
😎 Deploy Preview https://deploy-preview-3116--govuk-design-system-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@colinrotherham colinrotherham changed the title Various fixes for cookie banner buttons etc Various fixes for html-validate (cookie banner buttons) Sep 1, 2023
Base automatically changed from html-validate-fixes to main September 4, 2023 08:40
@colinrotherham colinrotherham added this to the v5.0 milestone Sep 5, 2023
}
]
}) }}
<form method="post">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this change, as it means clicking the accept / reject buttons in the example results in a POST to /styles/page-template/custom/.

On the Netlify preview, that results in a 404 with no page content (displays as a white screen in the iframe, and a Chrome error page if opened in a new tab). Not sure what the behaviour would be on PaaS.

I appreciate technically it's needed, but wonder if we should accept that this is only meant to be an illustration of how to customise parts of the page template and omit the form?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a very good point

How about we wire up preventFormSubmission() like on example pages?

Suggested change
<form method="post">
<form action="/form-handler" method="post" novalidate>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Pushed. The submit event is prevented like all the other iframes

.htmlvalidate.js Outdated
Comment on lines 22 to 23
// Allow implicit type="button" without type attribute
'no-implicit-button-type': 'off',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still needed because we haven't shipped the changes in alphagov/govuk-frontend#4113 yet, right?

I think if you don't have that context it's 'surprising' to see this included, given the other changes in this PR mean that we otherwise shouldn't need to disable the rule.

Suggest we either split this out, maybe into #3144, or at least add a note to the commit to explain why it's needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thinking. I've removed it from this PR as the rule doesn't exist yet until #3144

These examples currently use name/value pairs for form submission but prevent it with `type="button"`

Some necessary features for client-side use are missing too:

1. Message hidden by default users without JavaScript
2. Additional confirmation messages for accept/reject
3. Usage of `role="alert"` for confirmation messages

They can be better shown for server-side usage instead
Helps to reduce setup time by sharing form field name/value across pages

E.g. The same server-side middleware can respond to form submissions from either the banner or page
@colinrotherham colinrotherham merged commit 9246c1e into main Sep 20, 2023
@colinrotherham colinrotherham deleted the cookie-banner-buttons branch September 20, 2023 12:47
colinrotherham added a commit that referenced this pull request Sep 22, 2023
Although Design System buttons were all fixed in #3116 we need this line until alphagov/govuk-frontend#4113 is released
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assurance 🐛 bug Something isn't working the way it should (including incorrect wording in documentation) cookie banner
Projects
Development

Successfully merging this pull request may close these issues.

2 participants