Comments (3)
Firstly note that ::backdrop
doesn't support the polyfill, you'll also need + .backdrop
for that. The best practice needs two things-
- create a
div
that covers the entire dialog (position: absolute; width: 100%; height: 100%;
), remembering to set thedialog
toposition: relative
to contain it - add a click handler to the dialog itself
If you see a click on the dialog, i.e. where the event's target is the dialog, you know it must be the backdrop. Otherwise, the event's target would have been the covering div.
from dialog-polyfill.
Closing since this is not an issue.
from dialog-polyfill.
a possible alternative approach that doesn't require div tag soup:
when the dialog is opened:
- attach a click event handler to the body, which takes the event target and traverses up the
parentNode
s. If a<dialog>
element is one of the ancestors, close the dialog
when the dialog is closed:
- detach the body click event handler
from dialog-polyfill.
Related Issues (20)
- backdrop bug with multiple dialogs in safari
- Safari Experimental Feature "Dialog Element" doesn't fire "close" event HOT 3
- Safari 14.0.2 Backdrop and dialog content issue HOT 4
- Too long running function HOT 1
- Safari ignores onclose handler attribute
- Slotted elements which appear within a dialog due to slots but are declared outside of the dialog cannot get focus in Firefox and Safari HOT 2
- Attach css within the script HOT 2
- The "fixed" class no longer positions correctly in Chrome HOT 3
- On Firefox, shows this on console : "Error: Failed to execute 'close' on dialog..." HOT 6
- .
- Polyfill Demo not working in IE11 HOT 1
- Dialog changing from position `absolute` to `fixed`
- Prevent page scrolling while modal dialog is open HOT 3
- BSD is not a valid SPDX License identifier HOT 3
- Consider exporting base class `HTMLDialogElement` for subclassing HOT 2
- No support for imports from isomorphic scripts HOT 3
- Not working in Safari 15.3 HOT 1
- Polyfill injects overlay into <slot> on first render in iOS Safari <15.4 HOT 1
- How to determine if one should load the polyfill
- dialogPolyfill.forceRegisterDialog and browsers with native dialog support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dialog-polyfill.