Skip to content
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 useMenuItem onAction regression #6807

Merged
merged 2 commits into from
Aug 5, 2024
Merged

Conversation

snowystinger
Copy link
Member

Closes #6804

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

@rspbot
Copy link

rspbot commented Jul 31, 2024

it('calls an onAction passed directly to useMenuItem', async () => {
let onSelect = jest.fn();
let {getAllByRole} = render(
<Menu onSelect={onSelect} aria-label={'test menu'}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah interesting, so this is a route where the user passes their onAction equivalent at the menu level but routes it directly to the useMenuItem hook. I think when you and I discussed this previously that I had made an erroneous assumption that it would always be passed to the Menu or the Item as onAction directly whoops

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, all good, I didn't really understand until I saw an example as well.

@rspbot
Copy link

rspbot commented Aug 3, 2024

@snowystinger snowystinger merged commit 4969019 into main Aug 5, 2024
29 checks passed
@snowystinger snowystinger deleted the fix-menu-onAction-regression branch August 5, 2024 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

onAction doesn't get triggered for <MenuItem>s / useMenuItem()s
4 participants