Skip to content

[bug] keybing triggered unexpectedly even when the palette is not visible #16

@litanlitudan

Description

@litanlitudan

Hi folks,
Thanks for creating such a cool project, really a great job!

I tried to integrate this module into one of my projects and noticed that the keybinding got overwrote unexpectedly.
For example, once I add the component to my app, my upArrow key won't work anymore, even without the palette being visible.
I noticed that in the codebase, svelte-command-pallete disable the default behavior of the keystroke:

Is it possible to only enable the logic when the palette is visiable?
Also, there might be something wrong with my setup, as I am still learning svelte :)
Here is how I integrated the svelte-command-pallete
In file /component/commandPallete.svelte

<script lang="ts">
    import CommandPalette, { defineActions, createStoreMethods } from 'svelte-command-palette';

     // define actions using the defineActions API
    const commands = defineActions([
        {
            actionId: 1,
            title: "Open Svelte Command Palette on github",
            subTitle: "This opens github in a new tab!",
            onRun: ({ action, storeProps, storeMethods }) => {
                if (!storeProps.isVisible) {
                    return;
                }
                window.open("https://github.com/rohitpotato/svelte-command-palette");
            },
            shortcut: "Space k"
        }
    ]);
</script>

<CommandPalette {commands}/>

How I reference the component in the main app.svelte is as the following

<script lang="ts">
    import CommandPalette from "./components/CommandPalette.svelte";
</script>
<main>
  <CommandPalette/>
</main>

Any help is appreciated, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions