Skip to content

Commit 626ca15

Browse files
cubapthehabes
andauthored
Add closeNow and overlay pointer-events fix (#504)
Handle immediate dialog teardown and interaction blocking: register a 'tools-dismiss' listener to call closeNow, call closeNow during disconnectedCallback, and add a closeNow() method that clears any close timeout, removes 'show' classes from overlay/container, and invokes overlay.close(). Also update CSS to disable pointer events by default and enable them only when .show is present so the hidden overlay doesn't intercept clicks. Co-authored-by: Bryan Haberberger <bryan.j.haberberger@slu.edu>
1 parent faa5424 commit 626ca15

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

components/quicktype-tool/quicktype-editor-dialog.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class QuickTypeEditorDialog extends HTMLElement {
2828

2929
connectedCallback() {
3030
this.render()
31+
this.cleanup.onEvent(eventDispatcher, 'tools-dismiss', () => this.closeNow())
3132
}
3233

3334
disconnectedCallback() {
@@ -36,6 +37,7 @@ class QuickTypeEditorDialog extends HTMLElement {
3637
clearTimeout(this.#closeAnimationTimeout)
3738
this.#closeAnimationTimeout = null
3839
}
40+
this.closeNow()
3941
this.dialogCleanup.run()
4042
this.cleanup.run()
4143
}
@@ -76,6 +78,20 @@ class QuickTypeEditorDialog extends HTMLElement {
7678
}, 300)
7779
}
7880

81+
closeNow() {
82+
const overlay = this.shadowRoot.querySelector('.dialog-overlay')
83+
const container = this.shadowRoot.querySelector('.dialog-container')
84+
85+
if (this.#closeAnimationTimeout) {
86+
clearTimeout(this.#closeAnimationTimeout)
87+
this.#closeAnimationTimeout = null
88+
}
89+
90+
overlay?.classList?.remove('show')
91+
container?.classList?.remove('show')
92+
overlay?.close?.()
93+
}
94+
7995
addEventListeners() {
8096
// Clear previous dialog-specific listeners before adding new ones
8197
this.dialogCleanup.run()
@@ -402,13 +418,15 @@ class QuickTypeEditorDialog extends HTMLElement {
402418
max-width: 100vw;
403419
height: 100vh;
404420
max-height: 100vh;
421+
pointer-events: none;
405422
}
406423
407424
.dialog-overlay::backdrop {
408425
background: rgba(0, 0, 0, 0.6);
409426
}
410427
411428
.dialog-overlay.show {
429+
pointer-events: auto;
412430
background: rgba(0, 0, 0, 0.6);
413431
backdrop-filter: blur(2px);
414432
}

0 commit comments

Comments
 (0)