mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-19 00:02:03 +00:00
fix: prevent iframe from overriding file selection after file creation
When files change in the sidebar, setFilesInIframe sends the new files to the iframe which responds with setActiveDocument defaulting to App.tsx, overriding the user's selection. Now we ignore setActiveDocument messages for 500ms after sending setFiles to the iframe. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -164,10 +164,13 @@
|
||||
setFilesInIframe(files)
|
||||
}
|
||||
}
|
||||
let ignoreSetActiveDocument = false
|
||||
function setFilesInIframe(newFiles: Record<string, string>) {
|
||||
const files = Object.fromEntries(
|
||||
Object.entries(newFiles).filter(([path, _]) => !path.endsWith('/'))
|
||||
)
|
||||
ignoreSetActiveDocument = true
|
||||
setTimeout(() => (ignoreSetActiveDocument = false), 500)
|
||||
iframe?.contentWindow?.postMessage(
|
||||
{
|
||||
type: 'setFiles',
|
||||
@@ -612,6 +615,7 @@
|
||||
} else if (e.data.type === 'updateModules') {
|
||||
modules = e.data.modules
|
||||
} else if (e.data.type === 'setActiveDocument') {
|
||||
if (ignoreSetActiveDocument) return
|
||||
// Normalize Windows-style path separators to Linux-style
|
||||
selectedDocument = e.data.path?.replace(/\\/g, '/')
|
||||
} else if (e.data.type === 'inspectorSelect') {
|
||||
|
||||
Reference in New Issue
Block a user