Ensure button plugin sets/removes active class correctly on page load#28952
Merged
patrickhlauke merged 4 commits intoJun 24, 2019
Merged
Conversation
…s on page load Sanity check, ensures that the UI visually matches the actual values/states of controls. Also ensures that if any autocomplete/autofill happened, this is visually accounted for by having the correct class set. Includes unit tests (and `autocomplete` has been removed from these as it's no longer necessary)
As the attribute was there to force/ensure that the visual presentation matched the state, and this is now taken care of programmatically, there's no need to unnecessarily suppress autocomplete...let them autocomplete if they want to...
This was referenced Jun 24, 2019
Johann-S
reviewed
Jun 24, 2019
Johann-S
reviewed
Jun 24, 2019
Johann-S
reviewed
Jun 24, 2019
Johann-S
reviewed
Jun 24, 2019
Johann-S
approved these changes
Jun 24, 2019
XhmikosR
pushed a commit
that referenced
this pull request
Jun 26, 2019
…#28952) * Ensure correct active class is set on button toggles/checkboxes/radios on page load Sanity check, ensures that the UI visually matches the actual values/states of controls. Also ensures that if any autocomplete/autofill happened, this is visually accounted for by having the correct class set. Includes unit tests (and `autocomplete` has been removed from these as it's no longer necessary) * Remove now unnecessary autocomplete attribute As the attribute was there to force/ensure that the visual presentation matched the state, and this is now taken care of programmatically, there's no need to unnecessarily suppress autocomplete...let them autocomplete if they want to...
XhmikosR
pushed a commit
that referenced
this pull request
Jul 10, 2019
…#28952) * Ensure correct active class is set on button toggles/checkboxes/radios on page load Sanity check, ensures that the UI visually matches the actual values/states of controls. Also ensures that if any autocomplete/autofill happened, this is visually accounted for by having the correct class set. Includes unit tests (and `autocomplete` has been removed from these as it's no longer necessary) * Remove now unnecessary autocomplete attribute As the attribute was there to force/ensure that the visual presentation matched the state, and this is now taken care of programmatically, there's no need to unnecessarily suppress autocomplete...let them autocomplete if they want to...
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
More fundamentally fixes a problem with Bootstrap's "faked" toggles, checkboxes, radio buttons ... the fact that the visual presentation can get out of sync with the real value/state of controls if, for instance, autocomplete happened (which would change the underlying value, but not set the correct
activeclass). This does a sanity check on page load and makes sure theactiveclass is only set if the underlying control is really pressed/checked, and otherwise removes it. This guarantees that they're in sync from the moment the page is loaded, regardless of whether or not a browser did an autocomplete, or even the author forgot to set BOTH the class and the relevant attribute.Also, removes the now unnecessary
autocomplete="off"attributes used to essentially prevent out-of-sync situations from happening (in Firefox, primarily). Now, if Firefox does an autocomplete, this new logic ensures that theactiveclass will be correct, no problem.Closes #28623
Supersedes #28649
Could potentially be ported to v5, but once #28463 lands the part relating to checkboxes/radio buttons will be irrelevant ... will create a separate v5-specific patch to keep just the
aria-pressedtoggles in sync on page load (probably as part of that PR itself)