johnlindquist / kit

Script Kit. Automate Anything.
https://scriptkit.com
MIT License
3.84k stars 132 forks source link

File chooser in Form is unresponsive #1059

Open mstine opened 1 year ago

mstine commented 1 year ago

I'm working on a script to manage a collection of root paths organized according to the PARA method.

onTab("New", async () => {
    let [name, path] = await fields([
        {
            name: "name",
            label: "Name",
            type: "text",
            placeholder: "New PARA-Root:"
        },
        {
            name: "path",
            label: "Path",
            type: "file",
            placeholder: "Select or create path:"
        }
    ])
    roots.push({ name, path, id: uuid(), tag: "" })
    await write()
    setTab("PARA-Roots")
})

The above script is working otherwise properly, but nothing happens when I try to use the resulting file chooser to select a path.

image

No output appears in the logs or the dev console debugger (I've dropped debugger in a few different spots...). I've tried stepping through the code, but I'm struggling to get it to step into the actual Kit code.

Kit 1.40.62 Electron 22.0.0 linux 6.0.12-76060006-generic Locale: en-US

johnlindquist commented 1 year ago

@mstine I'll dig into this. For now, you can use one of these approaches:

// Primarily for mouse users. Opens system file picker
let filePath = await selectFile(
  `Pick a file to upload or something`
)

// Primarily for keyboard users. Opens custom file explorer (Untested on Linux 😅)
let songPath = await path({
  startPath: home("Music"),
  hint: "Pick your favorite song",
})

await editor({
  value: JSON.stringify({ filePath, songPath }),
  language: "json",
})