diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-02-12 06:43:14 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-02-12 08:04:28 -0400 |
commit | a304741f2358544406533a15a4b0b1a9a7a8077e (patch) | |
tree | 73a824451cb8df9130469dd867968ef5eb9d16d2 /src | |
parent | e4ba2fa8506c783401f0616245439785d058bb68 (diff) |
client: sidebar-search: mouse dynamics when recalling
This commit is a bit misleading because the work here actually replaced an attempt at using .select().
Diffstat (limited to 'src')
-rw-r--r-- | src/static/js/client/sidebar-search.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/static/js/client/sidebar-search.js b/src/static/js/client/sidebar-search.js index 2e350070..a5652412 100644 --- a/src/static/js/client/sidebar-search.js +++ b/src/static/js/client/sidebar-search.js @@ -72,6 +72,7 @@ export const info = { collapsedDetailsForTidiness: null, recallingRecentSearch: null, + recallingRecentSearchFromMouse: null, currentValue: null, @@ -317,6 +318,14 @@ export function mutatePageContent() { export function addPageListeners() { if (!info.searchInput) return; + info.searchInput.addEventListener('mousedown', _domEvent => { + const {state} = info; + + if (state.recallingRecentSearch) { + state.recallingRecentSearchFromMouse = true; + } + }); + info.searchInput.addEventListener('focus', _domEvent => { const {session, state} = info; @@ -328,6 +337,19 @@ export function addPageListeners() { } }); + info.searchLabel.addEventListener('click', domEvent => { + const {state} = info; + + if (state.recallingRecentSearchFromMouse) { + if (info.searchInput.selectionStart === info.searchInput.selectionEnd) { + info.searchInput.select(); + } + + state.recallingRecentSearchFromMouse = false; + return; + } + }); + info.searchInput.addEventListener('change', _domEvent => { const {state} = info; |