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

prevent default when showing dialog #2004

Merged
merged 2 commits into from
May 11, 2023

Conversation

keithamus
Copy link
Member

Description

In Chrome Dev with Experimental Web Platform features enabled, I noticed that pressing Enter on a button to open a dialog will also trigger a pointer event (simulating the click of the button). This happens in a task after the keypress, and so the code does the following:

  • Chrome fires a keypress event for the Enter key.
  • The Enter key is on a data-show-dialog-id button, so dialog.show() is called.
  • Chrome fires a click pointer event.
  • The dialog is in the open state, but the click event is on an element outside the dialog, so dialog.hide() is called.

The effect of this is that the dialog is never shown. We can combat this by calling event.preventDefault() on the click when the dialog is being shown. This prevents the pointer event from being fired.

Closes # (type the issue number after # if applicable; otherwise remove this line)

Integration

Does this change require any updates to code in production?

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews

@keithamus keithamus requested review from a team and camertron May 11, 2023 11:51
@changeset-bot
Copy link

changeset-bot bot commented May 11, 2023

🦋 Changeset detected

Latest commit: 6a59c6c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/view-components Patch

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

@github-actions github-actions bot added the javascript Pull requests that update Javascript code label May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
javascript Pull requests that update Javascript code patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant