material-web
material-web copied to clipboard
Closing dialog with "esc" does not remove scrim
What is affected?
Accessibility, Component
Description
When I close a dialog by pressing the "esc" key the dialog closes but the scrim remains, which I wouldn't expect it to.
Reproduction
https://stackblitz.com/edit/vitejs-vite-nzeagr?file=index.html
Workaround
I guess you could query for the presence of the scrim onClose and delete it if you found it.
Is this a regression?
No or unsure. This never worked, or I haven't tried before.
Affected versions
Failing in v1.1.1 and v1.0.0
Browser/OS/Node environment
Browser: Edge 120.0.2210.133 OS: Windows 11 10.0.22621 Node: v18.18.0 NPM: v10.2.3
I tried the workaround I suggested on StackBlitz, but looks like neither the close nor closed events fire when you hit Esc so it doesn't work. Perhaps that has something to do with the bug?
Ah looks like this is probably just #5330
Can you try using @material/web@nightly to see if that fixes it?
I upgraded to "@material/web": "^1.1.2-nightly.7dd7a68.0" and it's somewhat better but not quite fixed, now the position of my mouse seems to make a difference 😖
- Mouse hovering over the button that triggered the dialog: The scrim fails to dismiss ~90% of the time
- Mouse hovering anywhere else: The scrim successfully dismisses ~90% of the time
I've fiddled with having extra buttons and hovering over them instead, but it only seems to matter whether I'm hovering the button that triggered the dialog
I notice that after dismissing the dialog with "esc" that the button that triggered the dialog gains keyboard focus, whereas if I dismiss the dialog by clicking outside of it it doesn't. Could that have something to do with it?
Here's a video of me opening the dialog and hitting "esc" a bunch of times to show what I mean
https://github.com/material-components/material-web/assets/29500397/2736a251-03cd-48c7-a49c-1912cf3784cf
Hmm, does it work as expected on Safari and Firefox? If you have an old version of Chrome, does it work in 119?
I suspect it may be related to chrome's new CloseWatcher APIs introduced in 120.
Everything seems to work as expected in Firefox. I don't have an older version of Chrome to try it on I'm afraid