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 on clicks to avoid firefox crash #160

Merged
merged 1 commit into from
Dec 7, 2023

Conversation

keithamus
Copy link
Collaborator

Description

This fixes #139. Currently the demo page crashes in Firefox (without popovers enabled) if you click the "Click to toggle shadowed popover" button.

Looking through a crash log, we can see this is because Firefox tries to handle the popover using their popover logic, but the logic isn't guarded to check the feature flag, and it tries to get the element by its ID, which is empty. The empty id check fails for some reason, and we end up with a crash:

So, this is definitely a bug in Firefox. Exceptions like this shouldn't happen, I've filed https://bugzilla.mozilla.org/show_bug.cgi?id=1868740 and I'll work on a patch to fix it.

In the meantime, however, we have an opportunity to fix it ourselves, because postHandleEvent() will only be called if the event's default wasn't prevented. Consequently, simply adding event.preventDefault() in our JS fixes this issue.

Steps to test/reproduce

Show me

N/A

Copy link

netlify bot commented Dec 7, 2023

Deploy Preview for popover-polyfill ready!

Name Link
🔨 Latest commit 9eef4ea
🔍 Latest deploy log https://app.netlify.com/sites/popover-polyfill/deploys/657195cb7c04b90008f27e61
😎 Deploy Preview https://deploy-preview-160--popover-polyfill.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@jgerigmeyer jgerigmeyer left a comment

Choose a reason for hiding this comment

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

This is great -- thanks for looking into it! ✨

@jgerigmeyer jgerigmeyer merged commit cb911a5 into main Dec 7, 2023
7 checks passed
@jgerigmeyer jgerigmeyer deleted the prevent-default-on-clicks-to-avoid-firefox-crash branch December 7, 2023 16:51
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.

"Click to toggle shadowed Popover" crashes in Firefox 118
2 participants