From f0da3eb3b23dba630ad3c938b8364a9eeb8d4078 Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Fri, 29 Oct 2021 14:13:10 -0400 Subject: [PATCH] (core) Select previous search input when clicking the search icon Summary: Searching with the keyboard shortcut selected the previous search text in the search box, but using the Search icon did not. A user reported it as an inconvenience: having to manually delete the value before searching for a new one. Test Plan: Verified manually Reviewers: georgegevoian Reviewed By: georgegevoian Subscribers: georgegevoian Differential Revision: https://phab.getgrist.com/D3102 --- app/client/ui2018/search.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/client/ui2018/search.ts b/app/client/ui2018/search.ts index 7ca7e7c7..071b3367 100644 --- a/app/client/ui2018/search.ts +++ b/app/client/ui2018/search.ts @@ -124,8 +124,10 @@ const searchArrowBtnTooltipOptions: IHoverTipOptions = { export function searchBar(model: SearchModel, testId: TestId = noTestId) { let keepExpanded = false; + const focusAndSelect = () => { inputElem.focus(); inputElem.select(); }; + const commandGroup = createGroup({ - find: () => { inputElem.focus(); inputElem.select(); }, + find: focusAndSelect, // On Mac, Firefox has a default behaviour witch causes to close the search bar on Cmd+g and // Cmd+shirt+G. Returning false is a Mousetrap convenience which prevents that. findNext: () => { model.findNext().catch(reportError); return false; }, @@ -164,7 +166,7 @@ export function searchBar(model: SearchModel, testId: TestId = noTestId) { cssHoverCircle( cssTopBarBtn('Search', testId('icon'), - dom.on('click', () => inputElem.focus()) + dom.on('click', focusAndSelect), ) ), expandedSearch(