Overlay catches click when clicking the modal

So, I have an overlay with a Modal in the center of the screen. Inside is an input element that has a custom datalist beneath it. All behaves normal. When I click anything in the modal nothing odd happens and the clicks are correctly registered as the item being clicked on (e.target is logical). The modal is a child of the Overlay. When one or more items are added in the datalist, even without adding any additional event handlers, it makes clicks inside the modal register as if the overlay was clicked (e.target === e.currentTarget). I'm out of options since I cannot distinguish anymore what is actually clicked. Even adding a click handler on the Modal with e.stopPropagation() doesn't help, because it doesn't register as the modal being clicked at all. I've tried Z-index as well. This bevior is the same in FireFox and Safari. Any ideas as to what else I can try?
10 Replies
13eck
13eck12mo ago
Please create a minimal working (broken?) example in Codepen. Without setting code it’s impossible to say. See #How To Ask Good Questions for more info
Parsec
Parsec12mo ago
Copy. Working on it
Parsec
Parsec12mo ago
Weirdly enough I am unable to reproduce it in the pen. https://codepen.io/Parseq/pen/YzRVQzM
Chris
CodePen
YzRVQzM
...
13eck
13eck12mo ago
Just out of curiosity, why aren't you using the modal element built-in to HTML? https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog
: The Dialog element - HTML: HyperText Markup Language | MDN
The HTML element represents a dialog box or other interactive component, such as a dismissible alert, inspector, or subwindow.
Parsec
Parsec12mo ago
How far back can it be used for older browsers?
13eck
13eck12mo ago
13eck
13eck12mo ago
2014 for Chrome 2022 for Safari…so not that long there, I guess
Parsec
Parsec12mo ago
That's what I thought
13eck
13eck12mo ago
Do you need to support browsers that haven't been updated in over a year?
Parsec
Parsec12mo ago
Well, possibly older Macs yes Until I release an Electron-based app (if I do that)