Skip to content

Comments

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

Open
duncanmcclean wants to merge 4 commits into6.xfrom
bard-ctrl-k
Open

[6.x] Avoid opening Command Palette when Bard field is focused & text is selected#14019
duncanmcclean wants to merge 4 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.

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