mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-20 00:07:01 +00:00
fix: stop hidden session preview tabs from acting on keys (#12531)
* fix: stop hidden session preview tabs from acting on keys Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: type HostWindow key handlers as window keyboard handlers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
3591598d03
commit
5bf5ff28bc
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { preventDefault, stopPropagation } from 'svelte/legacy'
|
||||
|
||||
import { Button } from './common'
|
||||
@@ -169,7 +170,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={onKeyDown} />
|
||||
<HostWindow onkeydown={onKeyDown} />
|
||||
|
||||
{#snippet reachesAnyTagWarning(scoped: boolean)}
|
||||
Nothing fixed at its start or its end, so it allows anyone{scoped ? ' in its workspaces' : ''} to reach
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { dbManagerTabsStorageKey, dbTableLayoutStorageKey } from './dbManagerDrawerModel.svelte'
|
||||
import { DbManagerTabs, type DbManagerTabKind } from './dbManagerTabs.svelte'
|
||||
import DbSqlTab from './DbSqlTab.svelte'
|
||||
@@ -279,7 +280,7 @@
|
||||
export const tabsModel = () => tabs
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
<HostWindow
|
||||
onkeydown={(e) => {
|
||||
if (e.key === 'Escape') {
|
||||
if (replResultData) {
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
import { Button } from './common'
|
||||
import {
|
||||
@@ -1026,6 +1027,8 @@
|
||||
if (editing) cancelEdit()
|
||||
closeFormatOnOutsideClick(e)
|
||||
}}
|
||||
/>
|
||||
<HostWindow
|
||||
onkeydown={(e) => {
|
||||
if (formatting && e.key === 'Escape') formatting = undefined
|
||||
}}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { Button } from './common'
|
||||
import Modal2 from './common/modal/Modal2.svelte'
|
||||
import NewDataTableMigrationModal from './workspaceSettings/NewDataTableMigrationModal.svelte'
|
||||
@@ -136,7 +137,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={onKeyDown} />
|
||||
<HostWindow onkeydown={onKeyDown} />
|
||||
|
||||
<Modal2
|
||||
title={promptStatements.length > 1 ? 'Schema changes detected' : 'Schema change detected'}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { BROWSER } from 'esm-env'
|
||||
|
||||
import { buildWsUrl } from '$lib/wsUrl'
|
||||
@@ -2226,7 +2227,7 @@
|
||||
watch([() => customTsTypesData.current], setTypescriptCustomTypes)
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={onKeyDown} />
|
||||
<HostWindow onkeydown={onKeyDown} />
|
||||
<EditorTheme />
|
||||
{#if datatableForMigrations && $operatingWorkspace}
|
||||
<DdlMigrationGuard
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { createEventDispatcher, onDestroy, getContext, untrack } from 'svelte'
|
||||
import { getFirstStepSchema } from '$lib/components/flows/flowStore.svelte'
|
||||
import type { FlowEditorContext } from '$lib/components/flows/types'
|
||||
@@ -71,7 +72,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={handleKeydown} />
|
||||
<HostWindow onkeydown={handleKeydown} />
|
||||
|
||||
<div class="h-full">
|
||||
{#if schema && mod}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { overlayHostActive } from '$lib/components/common/overlayHost.svelte'
|
||||
import DeployOnBehalfOfDialog from '$lib/components/itemSettings/DeployOnBehalfOfDialog.svelte'
|
||||
import { deployAsksOnBehalfOf } from '$lib/components/itemSettings/onBehalfOf'
|
||||
import { movesToAnotherOwner } from '$lib/components/itemSettings/inheritedAccess'
|
||||
@@ -479,9 +481,11 @@
|
||||
// window handler; Editor/SimpleEditor/TemplateEditor re-broadcast it
|
||||
// (untyped event, hence the manual listener). A step's code editor also
|
||||
// flushes through its `formatAction`, and a redundant flush is a no-op.
|
||||
const hostActive = overlayHostActive()
|
||||
$effect(() => {
|
||||
window.addEventListener('wm-monaco-save-shortcut', saveDraft)
|
||||
return () => window.removeEventListener('wm-monaco-save-shortcut', saveDraft)
|
||||
const onSaveShortcut = () => hostActive() && saveDraft()
|
||||
window.addEventListener('wm-monaco-save-shortcut', onSaveShortcut)
|
||||
return () => window.removeEventListener('wm-monaco-save-shortcut', onSaveShortcut)
|
||||
})
|
||||
|
||||
// Materialize a brand-new flow's draft before the session preview loads it by
|
||||
@@ -1713,7 +1717,7 @@
|
||||
const flowHasChanged = $derived(flowPreviewContent?.flowHasChanged())
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={onKeyDown} />
|
||||
<HostWindow onkeydown={onKeyDown} />
|
||||
|
||||
{@render children?.()}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { type Job, JobService, type FlowModule, type RestartedFrom } from '$lib/gen'
|
||||
import { Button } from './common'
|
||||
import { createEventDispatcher, getContext } from 'svelte'
|
||||
@@ -153,7 +154,7 @@
|
||||
})
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={onKeyDown} />
|
||||
<HostWindow onkeydown={onKeyDown} />
|
||||
|
||||
<div class="flex flex-col space-y-2 h-screen bg-surface px-6 py-2 w-full" id="flow-preview-content">
|
||||
<div class="flex flex-row justify-between w-full items-center gap-x-2">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import {
|
||||
ApiError,
|
||||
type Job,
|
||||
@@ -369,7 +370,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={onKeyDown} />
|
||||
<HostWindow onkeydown={onKeyDown} />
|
||||
|
||||
<div class="flex flex-col space-y-2 h-screen bg-surface py-2 w-full" id="flow-preview-content">
|
||||
{#if render}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { type RunnableType } from '$lib/gen/index.js'
|
||||
import { sendUserToast } from '$lib/utils.js'
|
||||
import RunningJobSchemaPicker from '$lib/components/schema/RunningJobSchemaPicker.svelte'
|
||||
@@ -126,7 +127,7 @@
|
||||
let jobs = $derived(jobsLoader?.jobs ?? [])
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={handleKeydown} />
|
||||
<HostWindow onkeydown={handleKeydown} />
|
||||
|
||||
<div class="h-full max-h-full min-h-0 w-full flex flex-col gap-2 relative">
|
||||
<div class="grow-0" data-schema-picker>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import SimpleEditor from '$lib/components/SimpleEditor.svelte'
|
||||
import { createEventDispatcher, onDestroy, untrack } from 'svelte'
|
||||
import { setEditorUnparseable } from './pendingEditorFlush'
|
||||
@@ -106,7 +107,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={handleKeydown} />
|
||||
<HostWindow onkeydown={handleKeydown} />
|
||||
|
||||
<!-- Add a hidden button that can receive focus -->
|
||||
<button bind:this={focusTrap} class="sr-only" tabindex="-1" aria-hidden="true">Focus trap</button>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { Button } from '$lib/components/common'
|
||||
import { InputService, type Input, type RunnableType } from '$lib/gen/index.js'
|
||||
import { userStore } from '$lib/stores.js'
|
||||
@@ -227,7 +228,7 @@
|
||||
})
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={handleKeydown} />
|
||||
<HostWindow onkeydown={handleKeydown} />
|
||||
|
||||
<div class="w-full flex flex-col gap-1 h-full overflow-y-auto pb-4">
|
||||
{#if !noButton}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { overlayHostActive } from '$lib/components/common/overlayHost.svelte'
|
||||
import DeployOnBehalfOfDialog from '$lib/components/itemSettings/DeployOnBehalfOfDialog.svelte'
|
||||
import { deployAsksOnBehalfOf } from '$lib/components/itemSettings/onBehalfOf'
|
||||
import { movesToAnotherOwner } from '$lib/components/itemSettings/inheritedAccess'
|
||||
@@ -1320,6 +1322,7 @@
|
||||
return dropdownItems.length > 0 ? dropdownItems : undefined
|
||||
}
|
||||
|
||||
const hostActive = overlayHostActive()
|
||||
function onKeyDown(event: KeyboardEvent) {
|
||||
// Lowercased so Caps Lock (which yields `S`) still saves. Shift excluded:
|
||||
// Ctrl+Shift+S must reach the browser/OS.
|
||||
@@ -1337,8 +1340,9 @@
|
||||
// window handler above; Editor/SimpleEditor/TemplateEditor re-broadcast it
|
||||
// (untyped event, hence the manual listener).
|
||||
$effect(() => {
|
||||
window.addEventListener('wm-monaco-save-shortcut', saveDraft)
|
||||
return () => window.removeEventListener('wm-monaco-save-shortcut', saveDraft)
|
||||
const onSaveShortcut = () => hostActive() && saveDraft()
|
||||
window.addEventListener('wm-monaco-save-shortcut', onSaveShortcut)
|
||||
return () => window.removeEventListener('wm-monaco-save-shortcut', onSaveShortcut)
|
||||
})
|
||||
|
||||
let path: Path | undefined = $state(undefined)
|
||||
@@ -1548,7 +1552,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={onKeyDown} />
|
||||
<HostWindow onkeydown={onKeyDown} />
|
||||
{@render children?.()}
|
||||
|
||||
<DeployOnBehalfOfDialog
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { MultiplayerConnection } from '$lib/multiplayerConnection'
|
||||
import { paneMinPercent } from '$lib/utils/splitpaneSizing'
|
||||
import { processSecretArgs } from './secretArgUtils'
|
||||
@@ -1870,7 +1871,7 @@
|
||||
bind:job={testJob}
|
||||
/>
|
||||
|
||||
<svelte:window onkeydown={onKeyDown} />
|
||||
<HostWindow onkeydown={onKeyDown} />
|
||||
|
||||
<!-- Standalone triggerable registration for the script editor -->
|
||||
<div
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { Alert, Drawer, DrawerContent, Button, ButtonType } from '$lib/components/common'
|
||||
import { CornerDownLeft, Plus } from 'lucide-svelte'
|
||||
import InsertRow from './dbtable/InsertRow.svelte'
|
||||
@@ -49,7 +50,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
<HostWindow
|
||||
onkeydown={(e) => {
|
||||
if (drawerOpen && (e.ctrlKey || e.metaKey) && e.key === 'Enter') {
|
||||
onConfirm()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import '@xyflow/svelte/dist/base.css'
|
||||
import { randomUUID } from '$lib/utils/uuid'
|
||||
import { onMount } from 'svelte'
|
||||
@@ -2310,6 +2311,8 @@
|
||||
if (paneMenu && !(e.target as HTMLElement | null)?.closest('[data-pane-menu]'))
|
||||
paneMenu = undefined
|
||||
}}
|
||||
/>
|
||||
<HostWindow
|
||||
onkeydown={(e) => {
|
||||
if (e.key === 'Escape') paneMenu = undefined
|
||||
}}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<script lang="ts">
|
||||
import type { KeyboardEventHandler } from 'svelte/elements'
|
||||
import { overlayHostActive } from './overlayHost.svelte'
|
||||
|
||||
type KeyHandler = KeyboardEventHandler<Window>
|
||||
|
||||
// Use this instead of `<svelte:window onkeydown>` in anything that can render inside a
|
||||
// session preview tab: hidden tabs stay mounted, and their window listeners would
|
||||
// otherwise act on an editor the user cannot see.
|
||||
let { onkeydown, onkeydowncapture }: { onkeydown?: KeyHandler; onkeydowncapture?: KeyHandler } =
|
||||
$props()
|
||||
|
||||
const hostActive = overlayHostActive()
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
onkeydown={(e) => hostActive() && onkeydown?.(e)}
|
||||
onkeydowncapture={(e) => hostActive() && onkeydowncapture?.(e)}
|
||||
/>
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { overlayHostActive } from '$lib/components/common/overlayHost.svelte'
|
||||
const hostActive = overlayHostActive()
|
||||
import { ContextIconMap, type ContextElement } from './context'
|
||||
import { ArrowLeft, ChevronRight, FileCode, Code2, Table2 } from 'lucide-svelte'
|
||||
|
||||
@@ -95,6 +97,7 @@
|
||||
}
|
||||
|
||||
function handleKeyDown(e: KeyboardEvent) {
|
||||
if (!hostActive()) return
|
||||
if (stringSearch.length > 0) {
|
||||
// Navigation in search view (flat list)
|
||||
if (e.key === 'ArrowDown') {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { overlayHostActive } from '$lib/components/common/overlayHost.svelte'
|
||||
const hostActive = overlayHostActive()
|
||||
import DrillPicker from '$lib/components/DrillPicker.svelte'
|
||||
import type { DrillLeaf, DrillNode } from '$lib/components/drillPicker'
|
||||
import type { ChatCommandItem } from './global/core'
|
||||
@@ -55,7 +57,7 @@
|
||||
}
|
||||
|
||||
function onDocumentKeydown(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape' && !e.defaultPrevented) {
|
||||
if (hostActive() && e.key === 'Escape' && !e.defaultPrevented) {
|
||||
setShowing?.(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ On a workspace-leaf pick, emits a reference-only `WorkspaceScriptElement` /
|
||||
Content is materialized at message-prep time by `AIChatManager` — see PR #9216.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { overlayHostActive } from '$lib/components/common/overlayHost.svelte'
|
||||
const hostActive = overlayHostActive()
|
||||
import { Database, Diff, FileText, Folder, Layers } from 'lucide-svelte'
|
||||
import BarsStaggered from '$lib/components/icons/BarsStaggered.svelte'
|
||||
import FlowModuleIcon from '$lib/components/flows/FlowModuleIcon.svelte'
|
||||
@@ -376,7 +378,7 @@ Content is materialized at message-prep time by `AIChatManager` — see PR #9216
|
||||
// claimed the event (defensive — melt-ui doesn't currently
|
||||
// preventDefault on Esc, but a future host might).
|
||||
function onDocumentKeydown(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape' && !e.defaultPrevented) {
|
||||
if (hostActive() && e.key === 'Escape' && !e.defaultPrevented) {
|
||||
setShowing?.(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
// The editor for a dbt script, which is a PROJECT rather than a body of code:
|
||||
// a file tree, a descriptor, run arguments and a model graph.
|
||||
//
|
||||
@@ -353,7 +354,7 @@
|
||||
bind:job={testJob}
|
||||
/>
|
||||
|
||||
<svelte:window onkeydown={onKeyDown} />
|
||||
<HostWindow onkeydown={onKeyDown} />
|
||||
|
||||
<div class="border-b shadow-sm px-2 py-1 flex items-center gap-3 text-2xs">
|
||||
<span class="font-mono text-secondary truncate">{path ?? ''}__dbt/</span>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { overlayHostActive } from '$lib/components/common/overlayHost.svelte'
|
||||
import {
|
||||
DiffIcon,
|
||||
FlaskConical,
|
||||
@@ -254,6 +256,7 @@
|
||||
function saveDraft() {
|
||||
if (draftQuery) void UserDraftDbSyncer.flush(draftQuery)
|
||||
}
|
||||
const hostActive = overlayHostActive()
|
||||
function onKeyDown(event: KeyboardEvent) {
|
||||
if ((event.ctrlKey || event.metaKey) && !event.shiftKey && event.key.toLowerCase() === 's') {
|
||||
if (!draftQuery) return
|
||||
@@ -263,8 +266,9 @@
|
||||
}
|
||||
// Monaco swallows the keydown, so a focused code editor re-broadcasts it instead.
|
||||
$effect(() => {
|
||||
window.addEventListener('wm-monaco-save-shortcut', saveDraft)
|
||||
return () => window.removeEventListener('wm-monaco-save-shortcut', saveDraft)
|
||||
const onSaveShortcut = () => hostActive() && saveDraft()
|
||||
window.addEventListener('wm-monaco-save-shortcut', onSaveShortcut)
|
||||
return () => window.removeEventListener('wm-monaco-save-shortcut', onSaveShortcut)
|
||||
})
|
||||
|
||||
/** With auto-save off, edits wait for Ctrl/Cmd+S, and closing the dialog would leave them
|
||||
@@ -1001,4 +1005,4 @@
|
||||
{/if}
|
||||
|
||||
<!-- Capture: the form's fields stop the key on its way back up. -->
|
||||
<svelte:window onkeydowncapture={onKeyDown} />
|
||||
<HostWindow onkeydowncapture={onKeyDown} />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { Button } from '$lib/components/common'
|
||||
import { refreshStateStore } from '$lib/svelte5Utils.svelte'
|
||||
import { ButtonType } from '$lib/components/common/button/model'
|
||||
@@ -734,7 +735,7 @@
|
||||
</script>
|
||||
|
||||
<!-- Add svelte:window to listen for keyboard events -->
|
||||
<svelte:window onkeydown={handleKeydown} />
|
||||
<HostWindow onkeydown={handleKeydown} />
|
||||
|
||||
<!-- The edit toggle and the add-input target, shared by both panels below: chat mode
|
||||
carries a smaller set of side tabs, but the controls themselves must not differ. -->
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
import FlowScriptPickerQuick from '../pickers/FlowScriptPickerQuick.svelte'
|
||||
import { defaultScriptLanguages, processInlineLangs } from '$lib/scripts'
|
||||
@@ -309,7 +310,7 @@
|
||||
let hubOffset = $derived(aiSandboxOffset + aiSandboxRows.length)
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={onKeyDown} />
|
||||
<HostWindow onkeydown={onKeyDown} />
|
||||
<div class="flex flex-row grow min-w-0 divide-x relative bg-surface-tertiary rounded-md">
|
||||
{#if selectedKind != 'preprocessor'}
|
||||
<div class="h-full overflow-auto p-2 w-36 shrink-0 gap-1 flex flex-col">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { Pane, Splitpanes } from 'svelte-splitpanes'
|
||||
import { refreshStateStore } from '$lib/svelte5Utils.svelte'
|
||||
import Tab from '$lib/components/common/tabs/Tab.svelte'
|
||||
@@ -872,7 +873,7 @@
|
||||
})
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={onKeyDown} />
|
||||
<HostWindow onkeydown={onKeyDown} />
|
||||
|
||||
{#if flowModule.value}
|
||||
<div class="h-full bg-surface" bind:clientWidth={width}>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { createBubbler } from 'svelte/legacy'
|
||||
|
||||
const bubble = createBubbler()
|
||||
@@ -23,7 +24,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={onKeyDown} />
|
||||
<HostWindow onkeydown={onKeyDown} />
|
||||
<button
|
||||
class="px-3 py-2 gap-2 w-full text-left flex flex-row items-center transition-all rounded-md {selected
|
||||
? 'bg-surface-hover'
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { overlayHostActive } from '$lib/components/common/overlayHost.svelte'
|
||||
const hostActive = overlayHostActive()
|
||||
import type { FlowEditorContext } from '../types'
|
||||
import { refreshStateStore } from '$lib/svelte5Utils.svelte'
|
||||
import type { OpenInSessionSource } from '$lib/components/sessions/OpenInSessionButton.svelte'
|
||||
@@ -129,7 +131,7 @@
|
||||
if (!moveManager.movingModuleId) return
|
||||
|
||||
function onKeyDown(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape') {
|
||||
if (hostActive() && e.key === 'Escape') {
|
||||
moveManager.clearMoving()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { createEventDispatcher, getContext, onDestroy, onMount, untrack } from 'svelte'
|
||||
import StepGenQuick from '$lib/components/copilot/StepGenQuick.svelte'
|
||||
import FlowInputsQuick from '../content/FlowInputsQuick.svelte'
|
||||
@@ -187,7 +188,7 @@
|
||||
let displayPath = $derived(height > 480)
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={onAiKeyDown} />
|
||||
<HostWindow onkeydown={onAiKeyDown} />
|
||||
<div
|
||||
id="flow-editor-insert-module"
|
||||
class="flex flex-col h-full gap-2 max-w-full {small ? 'w-[450px]' : 'w-[650px]'}"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import type { SupportedLanguage } from '$lib/common'
|
||||
import Button from '$lib/components/common/button/Button.svelte'
|
||||
import LanguageIcon from '$lib/components/common/languageIcons/LanguageIcon.svelte'
|
||||
@@ -42,7 +43,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={handleKeydown} />
|
||||
<HostWindow onkeydown={handleKeydown} />
|
||||
|
||||
<Button
|
||||
id={`flow-editor-new-${lang}`}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import TopLevelNode from './TopLevelNode.svelte'
|
||||
|
||||
@@ -22,6 +23,6 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={handleKeydown} />
|
||||
<HostWindow onkeydown={handleKeydown} />
|
||||
|
||||
<TopLevelNode {label} {selected} returnIcon neutral onSelect={click} {onHover} />
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { createEventDispatcher, getContext, untrack } from 'svelte'
|
||||
import { Skeleton } from '$lib/components/common'
|
||||
import { classNames, createCache } from '$lib/utils'
|
||||
@@ -203,7 +204,7 @@
|
||||
})
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={onKeyDown} />
|
||||
<HostWindow onkeydown={onKeyDown} />
|
||||
{#if $disableHubStore}
|
||||
<!-- Hub disabled, show nothing -->
|
||||
{:else if hubNotAvailable}
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { createEventDispatcher, getContext, untrack } from 'svelte'
|
||||
import type { FlowEditorContext } from '../types'
|
||||
import { FlowService, ScriptService } from '$lib/gen'
|
||||
@@ -163,7 +164,7 @@
|
||||
f={(x) => (emptyString(x.summary) ? x.path : x.summary + ' (' + x.path + ')')}
|
||||
/>
|
||||
|
||||
<svelte:window onkeydown={onKeyDown} />
|
||||
<HostWindow onkeydown={onKeyDown} />
|
||||
{#if filteredItems}
|
||||
{#if filteredItems.length == 0}
|
||||
<div class="text-2xs text-primary font-light text-center py-2 px-3 items-center">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { overlayHostActive } from '$lib/components/common/overlayHost.svelte'
|
||||
import GraphZoomControls from './GraphZoomControls.svelte'
|
||||
import FlowPanelPlacementPicker from '$lib/components/flows/common/FlowPanelPlacementPicker.svelte'
|
||||
import { overlayStack } from '$lib/components/common/overlayHost.svelte'
|
||||
@@ -1129,8 +1130,10 @@
|
||||
})
|
||||
|
||||
// Add global keyboard event listener for selection controls
|
||||
const hostActive = overlayHostActive()
|
||||
onMount(() => {
|
||||
function globalKeyDownHandler(event: KeyboardEvent) {
|
||||
if (!hostActive()) return
|
||||
handleKeyDown(event)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { onDestroy, tick } from 'svelte'
|
||||
import { fade } from 'svelte/transition'
|
||||
import { type Job } from '../../gen'
|
||||
@@ -106,10 +107,8 @@
|
||||
})
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
onkeydown={({ key }) => ['Escape', 'Esc'].includes(key) && close()}
|
||||
onscrollcapture={(e) => open && !popupEl?.contains(e.target as Node) && close()}
|
||||
/>
|
||||
<HostWindow onkeydown={({ key }) => ['Escape', 'Esc'].includes(key) && close()} />
|
||||
<svelte:window onscrollcapture={(e) => open && !popupEl?.contains(e.target as Node) && close()} />
|
||||
<!-- `open` too: crossing from the trigger onto the portaled popup leaves the wrapper, and
|
||||
unmounting here would cancel a load still in flight. -->
|
||||
{#if hovered || open}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import { overlayHostActive } from '$lib/components/common/overlayHost.svelte'
|
||||
import { Pane, Splitpanes } from 'svelte-splitpanes'
|
||||
import { paneMinPercent } from '$lib/utils/splitpaneSizing'
|
||||
import RawAppInlineScriptsPanel from './RawAppInlineScriptsPanel.svelte'
|
||||
@@ -2601,9 +2603,11 @@ addEventListener('message', function (e) {
|
||||
// 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.
|
||||
const hostActive = overlayHostActive()
|
||||
$effect(() => {
|
||||
const onEscapeCapture = (e: KeyboardEvent) => {
|
||||
if (
|
||||
hostActive() &&
|
||||
e.key === 'Escape' &&
|
||||
(inspectorEnabled || inspectorElement || previewSelectors.length > 0)
|
||||
) {
|
||||
@@ -2665,8 +2669,9 @@ addEventListener('message', function (e) {
|
||||
// Monaco swallows Ctrl/Cmd+S in inline editors; Editor/SimpleEditor
|
||||
// re-broadcast it as `wm-monaco-save-shortcut` (untyped, hence manual listener).
|
||||
$effect(() => {
|
||||
window.addEventListener('wm-monaco-save-shortcut', flushDraft)
|
||||
return () => window.removeEventListener('wm-monaco-save-shortcut', flushDraft)
|
||||
const onSaveShortcut = () => hostActive() && flushDraft()
|
||||
window.addEventListener('wm-monaco-save-shortcut', onSaveShortcut)
|
||||
return () => window.removeEventListener('wm-monaco-save-shortcut', onSaveShortcut)
|
||||
})
|
||||
|
||||
function handleKeydown(e: KeyboardEvent) {
|
||||
@@ -2702,7 +2707,8 @@ addEventListener('message', function (e) {
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onmessage={listener} onkeydown={handleKeydown} onpagehide={closeExternalPreview} />
|
||||
<svelte:window onmessage={listener} onpagehide={closeExternalPreview} />
|
||||
<HostWindow onkeydown={handleKeydown} />
|
||||
<DarkModeObserver
|
||||
bind:darkMode
|
||||
on:change={() => {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { overlayHostActive } from '$lib/components/common/overlayHost.svelte'
|
||||
const hostActive = overlayHostActive()
|
||||
import type { Job } from '$lib/gen'
|
||||
import RunRow from './RunRow.svelte'
|
||||
import VirtualList from '@tutorlatin/svelte-tiny-virtual-list'
|
||||
@@ -71,7 +73,7 @@
|
||||
let hasClickFocus = $state(false)
|
||||
const keysPressed = useKeyPressed(['Shift', 'Control', 'Meta', 'A', 'ArrowDown', 'ArrowUp'], {
|
||||
onKeyDown(key, e) {
|
||||
if (!hasClickFocus) return
|
||||
if (!hasClickFocus || !hostActive()) return
|
||||
if (key === 'A' && (keysPressed.Control || keysPressed.Meta)) {
|
||||
if (batchRerunOptionsIsOpen) return
|
||||
e.preventDefault()
|
||||
|
||||
@@ -212,13 +212,18 @@
|
||||
// shared stack would let its overlays arbitrate Escape for the tab the user is looking at.
|
||||
let overlayHostEl: HTMLDivElement | undefined = $state()
|
||||
let hostDrawers = $state({ val: [] as string[] })
|
||||
// The panel is resized rather than unmounted, so the active tab of a panel that
|
||||
// is off screen is as invisible as a background tab.
|
||||
const onScreen = $derived(active && !collapsed)
|
||||
setOverlayHost({
|
||||
el: () => overlayHostEl,
|
||||
drawers: hostDrawers,
|
||||
// The panel is resized rather than unmounted, so the active tab of a panel that
|
||||
// is off screen is as invisible as a background tab.
|
||||
active: () => active && !collapsed
|
||||
active: () => onScreen
|
||||
})
|
||||
// A hidden tab must not hold focus: keys typed into it would edit an editor the user
|
||||
// cannot see. `inert` only covers focus; window and document listeners in the tab
|
||||
// still fire and ask `overlayHostActive()`.
|
||||
const inert = $derived(permissions.moveStarted || !onScreen)
|
||||
|
||||
let flashing = $state(false)
|
||||
let flashTimer: ReturnType<typeof setTimeout> | undefined
|
||||
@@ -320,7 +325,7 @@
|
||||
bind:this={overlayHostEl}
|
||||
class="absolute inset-0 flex flex-col min-h-0 bg-surface {visibility}"
|
||||
aria-hidden={!active}
|
||||
inert={permissions.moveStarted}
|
||||
{inert}
|
||||
>
|
||||
<!-- Only the side the tab shows is mounted. A hidden editor would be a second editor on
|
||||
the item's one cell that tab dedupe, reading URLs, cannot see; a hidden side's drawers
|
||||
@@ -424,7 +429,7 @@
|
||||
bind:this={overlayHostEl}
|
||||
class="absolute inset-0 flex flex-col min-h-0 bg-surface {visibility}"
|
||||
aria-hidden={!active}
|
||||
inert={permissions.moveStarted}
|
||||
{inert}
|
||||
>
|
||||
<!-- Waits for the host element, as the run form does: the editors' own drawers and
|
||||
modals portal when they mount, and resolve their host only then. -->
|
||||
@@ -441,7 +446,7 @@
|
||||
bind:this={overlayHostEl}
|
||||
class="absolute inset-0 flex flex-col min-h-0 bg-surface {visibility}"
|
||||
aria-hidden={!active}
|
||||
inert={permissions.moveStarted}
|
||||
{inert}
|
||||
>
|
||||
{#if overlayHostEl}
|
||||
{#await import('./PageListView.svelte')}
|
||||
@@ -463,7 +468,7 @@
|
||||
bind:this={overlayHostEl}
|
||||
class="absolute inset-0 flex flex-col min-h-0 bg-surface {visibility}"
|
||||
aria-hidden={!active}
|
||||
inert={permissions.moveStarted}
|
||||
{inert}
|
||||
>
|
||||
{#if overlayHostEl}
|
||||
{#await import('./RunViewerView.svelte')}
|
||||
@@ -487,7 +492,7 @@
|
||||
bind:this={overlayHostEl}
|
||||
class="absolute inset-0 flex flex-col min-h-0 bg-surface {visibility}"
|
||||
aria-hidden={!active}
|
||||
inert={permissions.moveStarted}
|
||||
{inert}
|
||||
>
|
||||
{#if artifact && runtime}
|
||||
<ArtifactViewer
|
||||
@@ -505,7 +510,7 @@
|
||||
bind:this={overlayHostEl}
|
||||
class="absolute inset-0 flex flex-col min-h-0 bg-surface {visibility}"
|
||||
aria-hidden={!active}
|
||||
inert={permissions.moveStarted}
|
||||
{inert}
|
||||
>
|
||||
<!-- Waits for the host element itself: Drawer portals when it mounts, and the portal
|
||||
action reads its target once, so a form mounted in the same pass as this div would
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import HostWindow from '$lib/components/common/HostWindow.svelte'
|
||||
import Label from '../Label.svelte'
|
||||
import { DatabaseIcon, Info, Loader2, Trash2 } from 'lucide-svelte'
|
||||
import ToggleButton from '../common/toggleButton-v2/ToggleButton.svelte'
|
||||
@@ -253,7 +254,7 @@
|
||||
})
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={handleKeydown} />
|
||||
<HostWindow onkeydown={handleKeydown} />
|
||||
|
||||
<Label label="Trigger captures" {headless} class="h-full {headless ? '' : 'flex flex-col gap-1'}">
|
||||
{#snippet header()}
|
||||
|
||||
Reference in New Issue
Block a user