mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-21 00:02:23 +00:00
fix(raw_apps): exit inspect mode on Escape
This commit is contained in:
@@ -1048,6 +1048,15 @@
|
||||
'*'
|
||||
)
|
||||
}
|
||||
// Escape inside the preview exits inspect mode — the keydown fires in
|
||||
// the iframe's document, so the parent window listener can't see it.
|
||||
previewIframe?.contentWindow?.addEventListener(
|
||||
'keydown',
|
||||
(e) => {
|
||||
if (e.key === 'Escape' && inspectorEnabled) disableInspector()
|
||||
},
|
||||
true
|
||||
)
|
||||
})
|
||||
})
|
||||
$effect(() => {
|
||||
@@ -1215,6 +1224,27 @@
|
||||
}
|
||||
}
|
||||
|
||||
function disableInspector() {
|
||||
if (!inspectorEnabled) return
|
||||
inspectorEnabled = false
|
||||
previewIframe?.contentWindow?.postMessage({ type: 'inspectorDisable' }, '*')
|
||||
}
|
||||
|
||||
// Escape exits inspect mode. We listen in the capture phase because a global
|
||||
// handler swallows Escape before it bubbles to <svelte:window>. The preview
|
||||
// iframe (separate document) is covered by its own listener on load.
|
||||
$effect(() => {
|
||||
const onEscapeCapture = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape' && inspectorEnabled) {
|
||||
disableInspector()
|
||||
e.stopImmediatePropagation()
|
||||
e.preventDefault()
|
||||
}
|
||||
}
|
||||
window.addEventListener('keydown', onEscapeCapture, true)
|
||||
return () => window.removeEventListener('keydown', onEscapeCapture, true)
|
||||
})
|
||||
|
||||
function handleKeydown(e: KeyboardEvent) {
|
||||
// Skip when typing in an input, textarea, or Monaco editor.
|
||||
const classes = (e.target as HTMLElement | null)?.className
|
||||
|
||||
Reference in New Issue
Block a user