Skip to content

Commit 13bfdf0

Browse files
committed
fix(ctrl+k behaviour): should trigger shortcuts while in text input
1 parent f6ba852 commit 13bfdf0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/sidebar/components/search/SearchIconButton.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ function useSearchKeyboardShortcuts(store: SidebarStore) {
3434

3535
const modifierKey = isMacOS() ? 'meta' : 'ctrl';
3636

37+
// When user is in an input field, respond to CMD-/CTRL-K keypresses,
38+
// but ignore '/' keypresses
3739
useShortcut(shortcuts.openSearch, openSearch, { ignoreWhenEditable: true });
38-
useShortcut(`${modifierKey}+k`, openSearch, { ignoreWhenEditable: true });
40+
useShortcut(`${modifierKey}+k`, openSearch, { ignoreWhenEditable: false });
3941
}
4042

4143
export default function SearchIconButton() {

src/sidebar/components/search/test/SearchIconButton-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ describe('SearchIconButton', () => {
199199
});
200200
});
201201

202-
it('does not open search panel if user is in an input field and presses "Ctrl-k"', () => {
202+
it('opens search panel if user is in an input field and presses "Ctrl-k"', () => {
203203
fakeIsMacOS.returns(false);
204204
const input = document.createElement('input');
205205
document.body.append(input);
@@ -220,7 +220,7 @@ describe('SearchIconButton', () => {
220220
}),
221221
);
222222

223-
assert.notCalled(fakeStore.openSidebarPanel);
223+
assert.calledWith(fakeStore.openSidebarPanel, 'searchAnnotations');
224224
} finally {
225225
input.remove();
226226
}

0 commit comments

Comments
 (0)