-
Notifications
You must be signed in to change notification settings - Fork 90
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
Clicking a submit button on it's top edge does not submit #545
Comments
After initial investigation on the x-gov slack channel it looks like it's caused by the Couple of options as I see it:
|
Using Edit: and |
Doesn't seem to be a problem here (same animation, not using Elements): (Making the button element an input type submit, the issue occurs on GOV.UK too) |
Looks like the example in @fofr comment uses a pseudo element to maintain the click area |
there seems to be a communal x-gov effort. When someone has a feasible solution, can they submit a PR please? |
Here’s the relevant CSS being used in the GOV.UK links @fofr posted: .button {
position: relative;
}
.button:before {
content: "";
height: 110%;
width: 100%;
display: block;
background: transparent;
position: absolute;
top: 0;
left: 0;
}
.button:active:before {
top: -10%;
height: 120%;
} …which comes from here in the Frontend Toolkit: https://github.com/alphagov/govuk_frontend_toolkit/blob/9abfaf9d2236a628aadc05244a7dd6ae8024505a/stylesheets/design-patterns/_buttons.scss#L108 …which was introduced in this commit by @timpaul: alphagov/govuk_frontend_toolkit@24e1906 |
OK, I’ve narrowed it down. Not buggy
Buggy
The problem is that, for some reason, The reason to use |
Yep, input elements are empty elements which means they do not support pseudo elements. Worth noting that there's a bug in IE7 too which could cause confusing behaviour:
This is something I've been thinking about for GOV.UK Frontend - at the minute our behaviour is to prefer inputs unless the user specifies HTML content, in which case we then opt for |
Both `<button type='submit'>Submit<button>` and `<input type='submit' value='Submit'>` can be used to submit a form. We have historically[1] used `<input>` because it’s better-supported by IE6 in that: - the `submit` attribute is mandatory on `<button>`, not on `<input>` - the `innerHTML` of a button will be submitted to the server, not the value (as in other browsers) Reasons to now use `<button>` instead: - IE6/7 support is no longer a concern (especially with deprecation of TLS 1.0 on the way) - Because an `<input>` element can’t have children, the pseudo-element hack[2] used to ensure the top edge of the button is clickable doesn’t work. We’re seeing this bug[3] affect real users in research. 1. We inhereted our buttons from Digital Marketplace, here is me making that change in their code: Crown-Commercial-Service/digitalmarketplace-frontend-toolkit@8df7e2e#diff-b1420f7b7a25657d849edf90a70ef541 2. alphagov/govuk_frontend_toolkit@24e1906#diff-ef0e4eb6f1e90b44b0c3fe39dce274a4R79 3. alphagov/govuk_elements#545
Both `<button type='submit'>Submit<button>` and `<input type='submit' value='Submit'>` can be used to submit a form. We have historically[1] used `<input>` because it’s better-supported by IE6 in that: - the `submit` attribute is mandatory on `<button>`, not on `<input>` - the `innerHTML` of a button will be submitted to the server, not the value (as in other browsers) Reasons to now use `<button>` instead: - IE6/7 support is no longer a concern (especially with deprecation of TLS 1.0 on the way) - Because an `<input>` element can’t have children, the pseudo-element hack[2] used to ensure the top edge of the button is clickable doesn’t work. We’re seeing this bug[3] affect real users in research. 1. We inhereted our buttons from Digital Marketplace, here is me making that change in their code: Crown-Commercial-Service/digitalmarketplace-frontend-toolkit@8df7e2e#diff-b1420f7b7a25657d849edf90a70ef541 2. alphagov/govuk_frontend_toolkit@24e1906#diff-ef0e4eb6f1e90b44b0c3fe39dce274a4R79 3. alphagov/govuk_elements#545
Both `<button type='submit'>Submit<button>` and `<input type='submit' value='Submit'>` can be used to submit a form. Historically `<input>` has been preferred because it’s better-supported by IE6 in that: - the `submit` attribute is mandatory on `<button>`, not on `<input>` - the `innerHTML` of a button will be submitted to the server, not the value (as in other browsers) Reasons to now use `<button>` instead: - IE6/7 support is no longer a concern (especially with deprecation of TLS 1.0 on the way) - Because an `<input>` element can’t have children, the pseudo-element hack[1] used to ensure the top edge of the button is clickable doesn’t work. Fixes alphagov#545 1. alphagov/govuk_frontend_toolkit@24e1906#diff-ef0e4eb6f1e90b44b0c3fe39dce274a4R79
@36degrees having just watched a user stumble into this bug in research, I think |
@quis That's really valuable feedback, thanks. |
Both `<button type='submit'>Submit<button>` and `<input type='submit' value='Submit'>` can be used to submit a form. Historically `<input>` has been preferred because it’s better-supported by IE6 in that: - the `submit` attribute is mandatory on `<button>`, not on `<input>` - the `innerHTML` of a button will be submitted to the server, not the value (as in other browsers) Reasons to now use `<button>` instead: - IE6/7 support is no longer a concern (especially with deprecation of TLS 1.0 on the way) - Because an `<input>` element can’t have children, the pseudo-element hack[1] used to ensure the top edge of the button is clickable doesn’t work. Fixes #545 1. alphagov/govuk_frontend_toolkit@24e1906#diff-ef0e4eb6f1e90b44b0c3fe39dce274a4R79
This should address the bug where `<input type="submit">` doesn't register clicks when the very top of the element is clicked[0] and is more in-line with the Design System guidance[1]. [0] alphagov/govuk_elements#545 [1] https://design-system.service.gov.uk/components/button/#default-buttons Fixes #295
Clicking an
input type="submit"
button stylised with thebutton
CSS class on it's top edge displays a click animation, but does not submit the form.How would you expect it to work?
The form should be submitted as normal.
How does it work currently?
The animation is displayed and element catches focus, but the click does not actually happen. Form is not submitted.
Explain the steps to reproduce the bug
input type="submit" class="button"
,Tell us about your environment
The text was updated successfully, but these errors were encountered: