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
fix(dropdown): focus behaviour on press / enter keydown #2970
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
🦋 Changeset detectedLatest commit: 6549a0b The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThe recent changes aim to improve the behavior of the Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 0
Review Details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (3)
- .changeset/heavy-kangaroos-stare.md (1 hunks)
- packages/components/dropdown/tests/dropdown.test.tsx (1 hunks)
- packages/components/dropdown/src/use-dropdown.ts (1 hunks)
Files skipped from review due to trivial changes (1)
- .changeset/heavy-kangaroos-stare.md
Additional comments not posted (2)
packages/components/dropdown/src/use-dropdown.ts (1)
147-147
: Ensure theautoFocus
property is correctly implemented and tested.This change correctly implements the
autoFocus: "first"
property to enhance keyboard accessibility by focusing the first item when the dropdown is activated. It's crucial to ensure that this behavior is covered by unit tests to prevent regressions in future updates.packages/components/dropdown/__tests__/dropdown.test.tsx (1)
542-622
: New test cases for keyboard interactions are comprehensive and well-structured.The new test cases effectively simulate user interactions with the keyboard (Enter and Space keys) and verify that the first item is focused as expected. This aligns well with the changes made in the
use-dropdown.ts
file and ensures that the new functionality behaves as intended.
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.
Actionable comments posted: 0
Review Details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!pnpm-lock.yaml
Files selected for processing (3)
- packages/components/dropdown/tests/dropdown.test.tsx (2 hunks)
- packages/components/dropdown/package.json (1 hunks)
- packages/components/dropdown/src/use-dropdown.ts (2 hunks)
Files skipped from review due to trivial changes (2)
- packages/components/dropdown/tests/dropdown.test.tsx
- packages/components/dropdown/package.json
Files skipped from review as they are similar to previous changes (1)
- packages/components/dropdown/src/use-dropdown.ts
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.
Actionable comments posted: 0
Review Details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (3)
- .changeset/heavy-kangaroos-stare.md (1 hunks)
- packages/components/dropdown/src/use-dropdown.ts (1 hunks)
- packages/components/menu/src/use-menu.ts (2 hunks)
Files skipped from review due to trivial changes (1)
- packages/components/dropdown/src/use-dropdown.ts
Files skipped from review as they are similar to previous changes (1)
- .changeset/heavy-kangaroos-stare.md
Additional comments not posted (2)
packages/components/menu/src/use-menu.ts (2)
122-122
: Ensure proper merging ofuserMenuProps
withotherProps
.The integration of
userMenuProps
into the state generation throughuseTreeState
is correctly implemented. This change should allow for more flexible configuration of the menu component, aligning with the PR's objectives to enhance keyboard interaction.
126-126
: Validate the extended use ofuserMenuProps
in ARIA menu props.The extension of
userMenuProps
into the ARIA menu props generation viauseAriaMenu
is correctly done. This ensures that any user-defined properties are considered in the ARIA attributes, which is crucial for accessibility and custom behavior.
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.
🚀
Closes #2863
📝 Description
As the doc stated, when keydown (press /enter) on the trigger, the first menu item should be focused. This PR is to cover this missing behaviour.
⛳️ Current behavior (updates)
🚀 New behavior
💣 Is this a breaking change (Yes/No):
📝 Additional Information
Summary by CodeRabbit
@nextui-org/test-utils
as a dependency for the dropdown component.