-
Notifications
You must be signed in to change notification settings - Fork 130
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
Document-level click event listening breaks inside web components #582
Comments
- Remove `data-a11y-dialog-hide` and use Stimulus data action approach - This ensures that our code is more agnostic to the third party library and can leverage our own DialogController behaviour - Works around ally-dialog issue KittyGiraudel/a11y-dialog#582 - Fixes wagtail#10924
- Remove `data-a11y-dialog-hide` and use Stimulus data action approach - This ensures that our code is more agnostic to the third party library and can leverage our own DialogController behaviour - Works around ally-dialog issue KittyGiraudel/a11y-dialog#582 - Fixes wagtail#10924
- Remove `data-a11y-dialog-hide` and use Stimulus data action approach - This ensures that our code is more agnostic to the third party library and can leverage our own DialogController behaviour - Works around ally-dialog issue KittyGiraudel/a11y-dialog#582 - Fixes wagtail#10924
- Remove `data-a11y-dialog-hide` and use Stimulus data action approach - This ensures that our code is more agnostic to the third party library and can leverage our own DialogController behaviour - Works around ally-dialog issue KittyGiraudel/a11y-dialog#582 - Fixes wagtail#10924
Hi @KittyGiraudel, that error was caused by the use of the non-standard I've refactored the codepen to use the standard approach of explicitly calling
Hope this helps. Thanks! |
Alright, I opened #589. I would love some review on it. :) |
- Remove `data-a11y-dialog-hide` and use Stimulus data action approach - This ensures that our code is more agnostic to the third party library and can leverage our own DialogController behaviour - Works around ally-dialog issue KittyGiraudel/a11y-dialog#582 - Fixes wagtail#10924
This comment was marked as off-topic.
This comment was marked as off-topic.
Thanks @digicase but that sounds like a Wagtail issue and not an a11y-dialog issue, so it's best to post it in Wagtail's issue tracker e.g. wagtail/wagtail#10924. And thank you very much @KittyGiraudel for the fix, I can't review it atm but I've asked my friend to review it if he has time. Hopefully he'll get to it soon! |
This comment was marked as off-topic.
This comment was marked as off-topic.
- Remove `data-a11y-dialog-hide` and use Stimulus data action approach - This ensures that our code is more agnostic to the third party library and can leverage our own DialogController behaviour - Works around ally-dialog issue KittyGiraudel/a11y-dialog#582 - Fixes #10924
LGTM! We are coming across the same issue using a11y dialog in web components when there are multiple dialogs |
I managed to get around this by setting a11y dialog to look at my host element in my modal component. That way the aria-modal attribute is attached at the light dom level and the event bubbling works. |
Ran into the same issue… we could benefit from the fix. Do you see any soon merge attempt of #589? |
Hey Sven! If you can confirm that the fix is working fine, I would be happy to release it. I never had any confirmation from anyone that this was indeed a decent fix, so I didn’t dare publishing it. :D |
I’ll try to test the fix, but maybe this needs some time… this error was reported to me where a team packed our components into a WC... I have to set up a test case. |
Gentle poke here. If anyone who experiences this issue wants to try out the fix from #589 (perhaps by manually modifying the code in |
Sorry, I’m sad, that I couldn’t test this out yet. :( If someone is faster and smarter to set up a test case, I’ll appreciate it. |
Merged, but not yet released. |
Done in version 8.1.0. 🎉 I know it took forever, but I’m pretty confident with the fix now. I’ve also added more tests, so this is quite good. I’m looking forward to hearing your thoughts when y’all have tried it. :) |
I believe we’ve identified a bug in v8.0.0 when a dialog is within a web component, due to the changes in #387 to support #367. When processed at the document level, the click on a
data-a11y-dialog-hide
element will be reported with the web component as the event target, rather than thedata-a11y-dialog-hide
element or one of its descendants.Here is a minimal demo to reproduce the issue: a11y-dialog v8.0.0 custom elements event delegation – CodePen. In the import map, I added the URL to the v7.4.0 release to confirm that it does work.
I can see three possible ways to fix this, though my understanding of event delegation with shadow DOM isn’t very good so there could well be better options.
A11yDialog
constructor to configure where click event listening happens. The default could be thedocument
, while web components implementations could provide theshadowRoot
.event.target
to something likeevent.composedPath()[0]
, otherwise keeping the logic the same.From my perspective the most compelling is option 2, or any alternative that also limits the amount of unnecessary click event processing. Three
Element.closest
calls per click on the page might not seem like a big deal but I would assume it’s very common to haveA11yDialog
instantiated multiple times (once per component that can trigger its own modal), on pages where there are other interactive elements. In our case I can foresee situations where we’d get close to 1000 unnecessaryElement.closest
calls per minute while users interact with our app due to click interactions on pages with multiple instances ofA11yDialog
.The text was updated successfully, but these errors were encountered: