qwik-ui icon indicating copy to clipboard operation
qwik-ui copied to clipboard

Use CloseWatcher API when supported in place of escape key handlers

Open lukewarlow opened this issue 1 year ago • 1 comments
trafficstars

This library should use the CloseWatcher API [1][2] in place of escape key listeners where it's supported. This allows components such as combobox to be dismissed using extra close signals (e.g. Android back gesture).

[1] https://html.spec.whatwg.org/multipage/interaction.html#the-closewatcher-interface [2] https://developer.chrome.com/blog/new-in-chrome-120#close-watcher

Native popover and dialog elements internally use this API so by supporting it Qwik-ui would better match the platform. It would also improve accessibility as Screen reader "close signals" such as Talkback's back gesture are also supported.

lukewarlow avatar Dec 16 '23 17:12 lukewarlow

https://close-watcher-demo.glitch.me/ contains a polyfill that could be used. Alternatively you could choose to just branch your logic using close watcher where supported or using the existing escape key handlers where it's not.

lukewarlow avatar Dec 16 '23 17:12 lukewarlow