diff --git a/.changeset/dvorak-shortcut-logical-key.md b/.changeset/dvorak-shortcut-logical-key.md new file mode 100644 index 000000000..ddbf72db0 --- /dev/null +++ b/.changeset/dvorak-shortcut-logical-key.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Match keyboard shortcuts by the logical character typed instead of the physical key position, so that ⌘-C no longer opens the Assistant on the Dvorak layout (and other non-QWERTY layouts). diff --git a/packages/gitbook/src/components/AIChat/AIChatInput.tsx b/packages/gitbook/src/components/AIChat/AIChatInput.tsx index a396ea1f6..4e7b8c49d 100644 --- a/packages/gitbook/src/components/AIChat/AIChatInput.tsx +++ b/packages/gitbook/src/components/AIChat/AIChatInput.tsx @@ -51,6 +51,9 @@ export function AIChatInput(props: { }, { enableOnFormTags: true, + // Match the logical character so Dvorak ⌘-C (physical "I" key) copies + // instead of focusing the Assistant input. RND-11340. + ignoreEventWhen: (e) => e.key.toLowerCase() !== 'i', } ); diff --git a/packages/gitbook/src/components/Search/SearchContainer.tsx b/packages/gitbook/src/components/Search/SearchContainer.tsx index 0e6911909..452eff295 100644 --- a/packages/gitbook/src/components/Search/SearchContainer.tsx +++ b/packages/gitbook/src/components/Search/SearchContainer.tsx @@ -69,6 +69,10 @@ export function SearchContainer({ }, { enableOnFormTags: true, + // Match the logical character typed, not the physical key position, so + // non-QWERTY layouts don't trigger the shortcut by position (e.g. on + // Dvorak the physical "K"/"I" keys produce other characters). RND-11340. + ignoreEventWhen: (e) => e.key.toLowerCase() !== 'k', } ); @@ -84,6 +88,9 @@ export function SearchContainer({ }, { enableOnFormTags: true, + // Match the logical character so Dvorak ⌘-C (physical "I" key) copies + // instead of opening the Assistant. RND-11340. + ignoreEventWhen: (e) => e.key.toLowerCase() !== 'i', } );