File tree Expand file tree Collapse file tree 1 file changed +13
-14
lines changed
Expand file tree Collapse file tree 1 file changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -192,20 +192,19 @@ export default class A11yDialog {
192192 // target
193193 // See: https://github.com/KittyGiraudel/a11y-dialog/issues/582
194194 const target = event . composedPath ( ) [ 0 ] as HTMLElement
195-
196- // We use `.closest(..)` and not `.matches(..)` here so that clicking
197- // an element nested within a dialog opener does cause the dialog to open
198- if ( target . closest ( `[${ SCOPE } -show="${ this . id } "]` ) ) {
199- this . show ( event )
200- }
201-
202- if (
203- target . closest ( `[${ SCOPE } -hide="${ this . id } "]` ) ||
204- ( target . closest ( `[${ SCOPE } -hide]` ) &&
205- target . closest ( '[aria-modal="true"]' ) === this . $el )
206- ) {
207- this . hide ( event )
208- }
195+ const opener = closest ( `[${ SCOPE } -show="${ this . id } "]` , target )
196+ const explicitCloser = closest ( `[${ SCOPE } -hide="${ this . id } "]` , target )
197+ const implicitCloser =
198+ closest ( `[${ SCOPE } -hide]` , target ) &&
199+ closest ( '[aria-modal="true"]' , target ) === this . $el
200+
201+ // We use `closest(..)` (instead of `matches(..)`) so that clicking an
202+ // element nested within a dialog opener does cause the dialog to open, and
203+ // we use our custom `closest(..)` function so that it can cross shadow
204+ // boundaries
205+ // See: https://github.com/KittyGiraudel/a11y-dialog/issues/712
206+ if ( opener ) this . show ( event )
207+ if ( explicitCloser || implicitCloser ) this . hide ( event )
209208 }
210209
211210 /**
You can’t perform that action at this time.
0 commit comments