From 0d67edee5cae7713282d7cc038de8661bc2a1580 Mon Sep 17 00:00:00 2001 From: "Sergei, NOVOZHILOV" Date: Mon, 11 Aug 2025 14:34:27 +0800 Subject: [PATCH] fix one letter search pop-up behaviour --- .../components/view-popup/find-popup.js | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/common/components/view-popup/find-popup.js b/src/common/components/view-popup/find-popup.js index 2f4abcd4d..9dca37d63 100644 --- a/src/common/components/view-popup/find-popup.js +++ b/src/common/components/view-popup/find-popup.js @@ -55,20 +55,26 @@ function FindPopup({ params, onChange, onFindNext, onFindPrevious, onAddAnnotati function handleInputKeyDown(event) { let key = getKeyCombination(event); let code = getCodeCombination(event); + + let actualQuery = inputRef.current.value; + let queryChanged = ( + actualQuery !== currentParamsRef.current.query + ); + if (key === 'Enter') { - if (params.active) { + if (params.active && !queryChanged) { onFindNext(); - } - else { - onChange({ ...params, active: true }); + } else { + setQuery(actualQuery); + onChange({ ...params, query:actualQuery, active: true }); } } else if (key === 'Shift-Enter') { - if (params.active) { + if (params.active && !queryChanged) { onFindPrevious(); - } - else { - onChange({ ...params, active: true }); + } else { + setQuery(actualQuery); + onChange({ ...params, query:actualQuery, active: true }); } } else if (key === 'Escape') { @@ -76,7 +82,7 @@ function FindPopup({ params, onChange, onFindNext, onFindPrevious, onAddAnnotati event.preventDefault(); event.stopPropagation(); } - else if (code === 'Ctrl-Alt-Digit1') { + else if (code === 'Ctrl-Alt-Digit1' && !queryChanged) { preventInputRef.current = true; if (params.result?.annotation) { onAddAnnotation({ ...params.result.annotation, type: 'highlight', color: tools['highlight'].color }, true); @@ -84,7 +90,7 @@ function FindPopup({ params, onChange, onFindNext, onFindPrevious, onAddAnnotati onChange({ ...params, popupOpen: false, active: false, result: null }); } } - else if (code === 'Ctrl-Alt-Digit2') { + else if (code === 'Ctrl-Alt-Digit2'&& !queryChanged) { preventInputRef.current = true; if (params.result?.annotation) { onAddAnnotation({ ...params.result.annotation, type: 'underline', color: tools['underline'].color }, true);