[menu-button] Prevent default for links to avoid double click events#812
Merged
chaance merged 1 commit intoreach:developfrom Jun 28, 2021
Merged
[menu-button] Prevent default for links to avoid double click events#812chaance merged 1 commit intoreach:developfrom
chaance merged 1 commit intoreach:developfrom
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 8a89495:
|
Contributor
Author
|
Oh wow, the codesandbox bot is awesome. It forked my reproduction from the issue and applied these changes? That's very cool, and a good way to show that the problem is fixed. |
chaance
reviewed
Jun 28, 2021
| // consistent behavior across menu items we'll trigger a click when | ||
| // the spacebar is pressed. | ||
| if (selected) { | ||
| event.preventDefault(); |
Member
There was a problem hiding this comment.
@IanVS Should this not be moved into the next if block? I don't think we want to preventDefault for buttons.
Member
There was a problem hiding this comment.
Ah nope, I'm totally wrong here since we were doing that already! Gonna poke around a bit for any unintended edge cases here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thank you for contributing to Reach UI! Please fill in this template before submitting your PR to help us process your request more quickly.
yarn test).yarn start).This pull request:
Fixes #811.
I found that without preventing the original event's default, I was getting two click events, and one would fire inside a Dialog that I was opening, immediately closing it. This ensures the original event is prevented when creating a new .click() on a link.