-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 new ariakit-based DropdownMenu
component
#54939
Conversation
Flaky tests detected in a5bb3e1. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6639667936
|
ee3e5c6
to
1c6171e
Compare
1c6171e
to
e8138be
Compare
Size Change: +7.8 kB (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
ca1cf02
to
1725347
Compare
* External dependencies | ||
*/ | ||
import { render, screen, waitFor } from '@testing-library/react'; | ||
import { press, click, hover, type } from '@ariakit/test'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With @diegohaz we came to the conclusion that @testing-library/user-event
's way of simulating user events (especially key presses) just doesn't work well with ariakit (likely it's related to flushing microtasks). Using @ariakit/test
instead seems to work well and allows us to write unit tests without any hacky workarounds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, just bear in mind that @ariakit/test
isn't as stable as @ariakit/react
. You can expect more breaking changes without any deprecation warnings (but it will be described in the changelog).
…eyboard and uncontrolled check/radio items
fc8ef66
to
650152e
Compare
@aaronrobertshaw , apart from the more design-related feedback, I should have addressed all of your other points. Regarding design-related feedback, I will discuss further with @jameskoster and other design folks and take it from there. @alexstine , thank you for sharing feedback! A couple of questions:
|
Sorry, it's in one of the storybook examples. There are menu options you cannot select with the keyboard. Not sure which ones though. I am traveling this week and cannot review this further until Sunday. |
@alexstine , I believe I understand what you meant about items not being clickable — a few items in the slotfill example had the On a separate note, I'd still like to understand better what you meant by "Mounting the menu seems sluggish", so that I can also look at potentially improving things there. Overall, I'd like to propose that we merge this PR as-is given its size, and continue the work with smaller follow-ups as needed. What do folks think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing on Storybook, I couldn't find any blocking issues. I believe this PR is good to be merged. Improvements can be made in follow-up PRs.
In WordPress#54939 a new test was added that depends on `@ariakit/test`. But, even though that package is not needed in the production code, it was (accidentally?) added to `dependencies` instead of `devDependencies`. This means everyone using `@wordpress/components` winds up having to install this package. Let's move it to devDependencies where it belongs.
* Package `@ariakit/test` should be a dev dependency In #54939 a new test was added that depends on `@ariakit/test`. But, even though that package is not needed in the production code, it was (accidentally?) added to `dependencies` instead of `devDependencies`. This means everyone using `@wordpress/components` winds up having to install this package. Let's move it to devDependencies where it belongs. * Add PR link to changelog * Remove extraneous `.`
Part of #50459
Requires #55365
What?
Add a new version of the
DropdownMenu
component based off theariakit
library.Note: The component should still be considered a WIP and will be tweaked and refined either in this PR or via follow-up PRs as it receives feedback and as it gets used throughout the codebase
Why?
We found a few blockers when working on the radix-ui based new version of
DropdownMenu
, and therefore we're trying a version based onariakit
insteadHow?
Next steps:
DropdownMenu
andMenuItem
Progress tracker
DropdownMenu
DropdownMenuItem
)DropdownMenuGroup
DropdownMenuGroupLabel
(orDropdownMenuLabel
)DropdownMenuItem
DropdownMenuCheckboxItem
DropdownMenuRadioItem
DropdownMenuSeparator
dir
attribute via HTMLhideOnEscape={ ( e ) => { e.stopPropagation(); return true; } }
Testing Instructions
npm run distclean && npm ci && npm run storybook:dev
DropdownMenuV2Ariakit
storybook examplesScreenshots or screencast
(ignore the fact that menu's popover is not aligned with the trigger when Storybook's sidebar is opened, as that's a
floating-ui
bug not related to this PR)dropdownmenu.mp4