Lexical: Fixed modals closing on clicks starting from within modals

Specifically on chromium browsers. Firefox was fine before.
Changes tested across both.
This commit is contained in:
Dan Brown
2026-09-07 16:13:09 +01:00
parent bb76d14f82
commit ff9755a32d
+12 -1
View File
@@ -72,12 +72,23 @@ export class EditorFormModal extends EditorContainerUiElement {
const wrapper = el('div', {class: 'editor-modal-wrapper'}, [modal]);
// Handle clicks but only when not started from within the modal
let mouseDownInModal = false;
modal.addEventListener('mousedown', () => {
mouseDownInModal = true;
});
wrapper.addEventListener('mouseup', () => {
window.setTimeout(() => {
mouseDownInModal = false;
}, 10);
});
wrapper.addEventListener('click', event => {
if (event.target && !modal.contains(event.target as HTMLElement)) {
if (!mouseDownInModal) {
this.hide();
}
});
// Handle escape key press
wrapper.addEventListener('keydown', event => {
if (event.key === 'Escape') {
this.hide();