-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add a custom toggler hook and use it to fix Dropdown and ad hoc toggles #30397
Closed
Conversation
This file contains 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
Size Change: +352 B (0%) Total Size: 1.42 MB
ℹ️ View Unchanged
|
This was referenced Mar 31, 2021
This reverts commit 0ba62a7aa358df22e4ba29a2ae23f0963d254297.
Also: * Added use of aria-expanded attribute * Added anchorRef on popover for better positioning
stokesman
force-pushed
the
try/enhance-dropdown
branch
from
April 5, 2021 21:44
7528879
to
fe5b020
Compare
stokesman
changed the title
Enhance Dropdown flexibility and its toggle logic
Add a custom toggler hook and use it to fix Dropdown and ad hoc toggles
Apr 5, 2021
7 tasks
7 tasks
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.
An alternative to #27406 coinciding more with the approach recommended here: #30392 (comment)
Why
The issue is toggle buttons for popovers that don't close the popover as expected. When part of a
Dropdown
component the toggle works fine in common browsers but fails in some UAs (e.g. Firefox on macOS and Safari) that do not focus button elements when pressed.How
A custom hook has been added that gives back handlers to ease implementor boilerplate in making toggles that work in tandem with popovers auto-closing behavior (because that should be canceled in cases that pressing the toggle was what caused the auto-close). The hook has been used to refactor
Dropdown
but the implementors of it need minor updates to get the improved toggle logic (that doesn't break on the aforementioned UAs).DropdownMenu
has also been updated and its implementors need no changes to use the improved toggle logic. As an example of refactoring an ad hoc dropdown-like component, thePostDate
block was updated to use the new hook for its date picker. There are various others like it that should receive similar treatment as they don't currently toggle properly even in UAs that do focus buttons when pressed.Ongoing
If this approach gets a green light here are some things left to do:
Dropdown
implementorsHow has this been tested?
Manually in Chrome and Firefox on macOS by interacting with any of the dropdowns affected by the PR and many that are not. All is well so far.
Screenshots
Types of changes
Bug fix #29746 and new features
Checklist:
*.native.js
files for terms that need renaming or removal).