I want this to work personally and it's also part of the spec, but the library I'm using doesn't support it:
google/material-design-lite#5030
There's a workaround solution proposed here: google/material-design-lite#5030
document.querySelector('.dialog-show').addEventListener('click', function() {
document.querySelector('dialog').showModal();
document.querySelector('dialog').addEventListener('click', outsideDialog);
});
function outsideDialog(event) {
var dialog = this;
var rect = dialog.getBoundingClientRect();
var isInDialog = (
rect.top <= event.clientY && event.clientY <= rect.top + rect.height &&
rect.left <= event.clientX && event.clientX <= rect.left + rect.width
);
if (!isInDialog) {
dialog.close();
dialog.removeEventListener('click', outsideDialog);
}
}
I want this to work personally and it's also part of the spec, but the library I'm using doesn't support it:
google/material-design-lite#5030
There's a workaround solution proposed here: google/material-design-lite#5030