Update disable-on-submit styling to use active styling#6564
Conversation
5e2f484 to
cda74cc
Compare
So in spirit I agree with this... we should be able to handle double submissions, but we have had errors in the past, which is why we added this... here's an old ticket that's not super specific... but just to highlight that we don't have good visibility into which forms tend to get double submitted right now, but we've had errors times in LG history attributed to this |
Thanks for the extra context. As you mention, it's kinda hard to tell what forms may still be problematic. Maybe we pivot the other direction then, and make sure we're consistent with all submission buttons being disabled? I recall chatting about this at some point in the past with @anniehirshman-gsa , not sure how strongly you had felt about that Annie. I don't especially love the disable-on-submit behavior, though I'm more concerned with consistency above all else. Coincidentally, I had been contemplating the addition of a new |
|
I'm with Zach here. Some of the bugs we had with double submitting in the past were very tricky. I don't like the disable functionality either, but I do think aiming for consistency is probably the safer option |
|
Update: I chatted with @anniehirshman-gsa about this and we may want to standardize on the "always disable" approach, but also want to explore using the SpinnerButton / design system "Active" styling instead of the gray disabling for the pending submission. I will plan to make those updates here, but this work is lower priority, so I won't be able to get to it immediately. |
**Why**: - Improve consistency: Currently, this behavior happens in some forms and not others. This makes it so that a button is never disabled on form submission. - It's unnecessary: Our controllers should be tolerant to handling repeated submissions, and if they aren't, that should be addressed at the controller level, and not by relying on some fragile/unpredictable client-side behavior. - Contributing toward an eventual removal of the `form-validation` JavaScript pack changelog: Improvements, Forms, Improve consistency of form submission by leaving buttons enabled after submission
This reverts commit 0d3193a.
cda74cc to
fde066b
Compare
Only use when explicitly applied, since otherwise if the user clicks on a grayed, disabled button, they'd get the blue background only while mouse is held down
|
Circling back to this, I spent some time on Friday afternoon to get this updated with the proposal to use the active styling on submit. I think the new effect is a good compromise? I also checked with @anniehirshman-gsa and have added to the biweekly design system sync (at least to get some buy-in to the general approach for disable-on-submit). I marked the pull request as ready to review, and updated the original title and description with new details and before/after screen recordings. |
| /** @type {HTMLInputElement[]} */ | ||
| const fields = Array.from(form.querySelectorAll('.field,[required]')); | ||
| export function initialize(form: HTMLFormElement) { | ||
| const fields: HTMLInputElement[] = Array.from(form.querySelectorAll('.field,[required]')); |
There was a problem hiding this comment.
another idea about a space
| const fields: HTMLInputElement[] = Array.from(form.querySelectorAll('.field,[required]')); | |
| const fields: HTMLInputElement[] = Array.from(form.querySelectorAll('.field, [required]')); |
|
|
||
| .usa-button:disabled.usa-button--active, | ||
| .usa-button--disabled.usa-button--active { | ||
| @include set-text-and-bg('primary-darker', $context: 'Button'); |
There was a problem hiding this comment.
👀 I have never seen kwards in SCSS like this, what a time to be alive
There was a problem hiding this comment.
👍 For context, the general approach here is just to repeat the same styles as the default active styles from USWDS, but with higher specificity to make sure the active styles override the disabled styles.
https: //github.com//pull/6564#discussion_r940379678 Co-Authored-By: Zach Margolis <zbmargolis@gmail.com>
**Why**: Because the styling was only implemented with the expectation of use with the default button, and conflicts with other button states (e.g. unstyled buttons used as the submit buttons on some forms). Previously: #6564 changelog: Improvements, Forms, Use pressed state appearance for buttons disabled on form submission
* Remove upstream-patched disabled button styling See: uswds/uswds#4077 * Limit active disabled button styles to default button **Why**: Because the styling was only implemented with the expectation of use with the default button, and conflicts with other button states (e.g. unstyled buttons used as the submit buttons on some forms). Previously: #6564 changelog: Improvements, Forms, Use pressed state appearance for buttons disabled on form submission
**Why**: Because the spinner button retains its original shape by setting the text color to transparent, which was being overridden by the new active styles introduced in #6564. changelog: Bug Fixes, Buttons, Fix spinner button active state appearance
**Why**: Because the spinner button retains its original shape by setting the text color to transparent, which was being overridden by the new active styles introduced in #6564. changelog: Bug Fixes, Buttons, Fix spinner button active state appearance
Why:
Screen recording:
Before:
disable-before.mov
After:
disable-after.mov
Background:
Previously, this pull request was aimed at removing the disable-on-submit effect altogether:
Click to see previous summary
Why:
form-validationJavaScript packform-validationpack is in the critical path for JavaScript (sign-in page), and reduction in its code size should contribute to smaller bundle sizes and faster page loads