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

[menu-button] Prevent default for links to avoid double click events #812

Merged
merged 1 commit into from
Jun 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/menu-button/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,10 @@ const MenuItems = React.forwardRef(function MenuItems(
// consistent behavior across menu items we'll trigger a click when
// the spacebar is pressed.
if (selected) {
event.preventDefault();
Copy link
Member

Choose a reason for hiding this comment

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

@IanVS Should this not be moved into the next if block? I don't think we want to preventDefault for buttons.

Copy link
Member

Choose a reason for hiding this comment

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

Ah nope, I'm totally wrong here since we were doing that already! Gonna poke around a bit for any unintended edge cases here.

if (selected.isLink && selected.element) {
selected.element.click();
} else {
event.preventDefault();
// Focus the button first by default when an item is selected.
// We fire the onSelect callback next so the app can manage
// focus if needed.
Expand Down