From bb58f22c1186563e4e0ddea768d36e132f7ff18f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Obermu=CC=88ller?= Date: Wed, 15 Nov 2023 15:52:26 +0100 Subject: [PATCH] enter command mode when replacing selection --- .../src/lib/components/CommandBar/searchBarLogic.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/components/CommandBar/searchBarLogic.ts b/frontend/src/lib/components/CommandBar/searchBarLogic.ts index c97781bf2141d..fd69e079ec1a5 100644 --- a/frontend/src/lib/components/CommandBar/searchBarLogic.ts +++ b/frontend/src/lib/components/CommandBar/searchBarLogic.ts @@ -115,8 +115,14 @@ export const searchBarLogic = kea([ // hide command bar actions.hideCommandBar() } else if (event.key === '>') { - if (values.searchQuery.length === 0) { - // transition to actions when entering '>' with empty input + const { value, selectionStart, selectionEnd } = event.target as HTMLInputElement + if ( + values.searchQuery.length === 0 || + (selectionStart !== null && + selectionEnd !== null && + (value.substring(0, selectionStart) + value.substring(selectionEnd)).length === 0) + ) { + // transition to actions when entering '>' with empty input, or when replacing the whole input event.preventDefault() actions.setCommandBar(BarStatus.SHOW_ACTIONS) }