-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 DropdownItem onPress #2746
Fix DropdownItem onPress #2746
Conversation
🦋 Changeset detectedLatest commit: 70bd1b9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 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 |
WalkthroughThis set of changes primarily enhances the handling of press events in dropdown and menu components within the NextUI framework. It introduces new hooks for better ARIA compliance and revises existing components to improve interaction handling. The updates address specific bugs related to event handling in dropdown items, ensuring that press events are effectively managed and that components close correctly upon selection. Changes
Assessment against linked issues
The changes effectively address the issues reported in #2743 and #2751, focusing on improving event handling and ARIA compliance in dropdown and menu components. The updates ensure that press events are managed correctly and that components behave as expected upon user interactions. Recent Review DetailsConfiguration used: .coderabbit.yaml Files ignored due to path filters (1)
Files selected for processing (13)
Files skipped from review due to trivial changes (2)
Additional Context UsedLanguageTool (3)
Additional comments not posted (15)
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 (
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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: 5
} = props; | ||
|
||
let isTrigger = !!hasPopup; | ||
// @ts-ignore |
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.
Usage of @ts-ignore
to bypass TypeScript checks.
Avoid using @ts-ignore
as it bypasses TypeScript's static type checking. If there are type issues, consider fixing them or using more specific TypeScript utilities like type assertions or conditional types.
let isSelected = props.isSelected ?? state.selectionManager.isSelected(key); | ||
let data = menuData.get(state); | ||
// @ts-ignore | ||
let onClose = props.onClose || data.onClose; |
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.
Usage of @ts-ignore
to bypass TypeScript checks.
Repeated use of @ts-ignore
can lead to potential bugs going unnoticed. Review the necessity of this and consider alternatives.
setTimeout(() => { | ||
performAction(e); | ||
}); | ||
// // Pressing a menu item should close by default in single selection mode but not multiple | ||
// // selection mode, except if overridden by the closeOnSelect prop. | ||
if ( | ||
!isTrigger && | ||
onClose && | ||
(closeOnSelect ?? | ||
(state.selectionManager.selectionMode !== "multiple" || | ||
// @ts-ignore | ||
state.selectionManager.isLink(key))) | ||
) { | ||
setTimeout(() => { | ||
onClose?.(); | ||
}); | ||
} |
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.
Delay in action performance and menu closure.
Using setTimeout
to delay the execution of performAction
and onClose
might lead to a less responsive user experience. Consider alternatives that do not involve arbitrary delays.
"@nextui-org/use-aria-menu": patch | ||
--- | ||
|
||
Fix #2743 #2751 internal react-aria use-menu hooks implemented to pass down the press events and control the pressUp one |
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.
Fix the spelling mistake in "pressUp".
- control the pressUp one
+ control the `pressUp` one
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
Fix #2743 #2751 internal react-aria use-menu hooks implemented to pass down the press events and control the pressUp one | |
Fix #2743 #2751 internal react-aria use-menu hooks implemented to pass down the press events and control the `pressUp` one |
|
||
## Contribution | ||
|
||
Yes please! See the |
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.
Add a comma after "Yes" for grammatical correctness.
- Yes please! See the
+ Yes, please! See the
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
Yes please! See the | |
Yes, please! See the |
📝 Description
For some reason the react-aria
pressUp
event is breaking theonClick
/onPress
callback, to fix this we had to implement our own use-menu-item hook and control the pressUp event, in addition, we passed down the properties to control the press events directly.⛳️ Current behavior (updates)
Press / onClick events are not working on menu based components like Listbox / Dropdown / Menu / Etc
🚀 New behavior
Press events fixed
💣 Is this a breaking change (Yes/No): No
📝 Additional Information
Summary by CodeRabbit
New Features
closeOnSelect
andonClose
options for better user control.@nextui-org/use-aria-menu
for improved menu accessibility and behavior.Bug Fixes
Documentation
@nextui-org/use-aria-menu
detailing internal utility components.Tests
Refactor