(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
pull/115/head
Dmitry S 3 years ago
parent c5db65d1d2
commit f0da3eb3b2

@ -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(

Loading…
Cancel
Save