Skip to content

[6.x] Avoid opening Command Palette when Bard field is focused & text is selected#14019

Merged
jasonvarga merged 7 commits into6.xfrom
bard-ctrl-k
Mar 6, 2026
Merged

[6.x] Avoid opening Command Palette when Bard field is focused & text is selected#14019
jasonvarga merged 7 commits into6.xfrom
bard-ctrl-k

Conversation

@duncanmcclean
Copy link
Member

This pull request fixes an issue where cmd+k to open the Bard link stack conflicts with mod+k to open the Command Palette.

This PR fixes it by opening the link stack when text is selected and opening the Command Palette when it's not.

Fixes #14009

Copy link
Member

@jasonvarga jasonvarga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love having Bard code inside command palette. I wonder if there's an alternative.

@duncanmcclean
Copy link
Member Author

I've refactored it to use a callback approach instead...

Statamic.$commandPalette.preventIf(() => {
    const selection = window.getSelection();
    const node = selection?.anchorNode;
    const isInBard = node?.parentElement?.closest('.bard-editor') !== null;
    return isInBard && selection?.toString().length > 0;
});

Let me know what you think.

@jasonvarga
Copy link
Member

This works nicely. Thanks.

However since it prevents cmd+k when you have text selected in bard, cmd+k will do absolutely nothing on a mac. No link popover, no command palette.

So I've switched the bard link shortcut back to cmd+k. The only reason we changed it from cmd was because of the command palette conflict. Now that its back to cmd, it matches cmd+b for bold, etc.

@jasonvarga jasonvarga merged commit ede343c into 6.x Mar 6, 2026
17 checks passed
@jasonvarga jasonvarga deleted the bard-ctrl-k branch March 6, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ctrl + K brings up multiple panels

2 participants