I’m exploring replacing some JavaScript modals with native HTML and CSS only modals using the new Popover API and I’ve noticed that pointer-events like hover and click are propagating through to the underlying layer.
::backdrop {
background: rgba(255, 255, 255, 0.4);
backdrop-filter: grayscale(40%) blur(3px);
}
<button popovertarget="mypopover" popovertargetaction="show">
Show popover
</button>
<div id="mypopover" popover>Popover content</div>
<a href="https://google.com"/>Links</a>
How can I prevent clicks propagating to underlying layer elements when the ::backdrop
is being shown? I’ve attempted pointer-events: none
but seen no success.
If it’s not currently possible, are there browser bugs to follow for tracking this functionality?
2
Answers
Maybe this is a dirty option, but you can close the space with other elements in
popover
:You may also try to filter popover-open and reset pointer-events on a few elements :
CSS idea is:
Look at https://developer.mozilla.org/en-US/docs/Web/CSS/:popover-open to find your own use
caniuse ? https://caniuse.com/?search=%3Apopover-open