From f6e8099bc2a6acd9b52eb617641f802e25aca5fa Mon Sep 17 00:00:00 2001 From: NikolaBorislavovHristov Date: Thu, 16 May 2019 19:29:08 +0300 Subject: [PATCH] SearchBar static placeholder rendered on non search routes --- src/common/NavBar/SearchBar/SearchBar.js | 48 +++++++++++++----------- src/common/NavBar/SearchBar/styles.less | 9 ++++- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/common/NavBar/SearchBar/SearchBar.js b/src/common/NavBar/SearchBar/SearchBar.js index 3b989a70c..0d10a784a 100644 --- a/src/common/NavBar/SearchBar/SearchBar.js +++ b/src/common/NavBar/SearchBar/SearchBar.js @@ -18,11 +18,9 @@ const SearchBar = React.memo(({ className }) => { const query = (active && queryParams.has('q')) ? queryParams.get('q') : ''; return [active, query]; }, [locationHash]); - const onQueryInputFocus = React.useCallback(() => { - if (!active) { - window.location = '#/search'; - } - }, [active]); + const navigateToSearch = React.useCallback(() => { + window.location = '#/search'; + }, []); const onQueryInputSubmit = React.useCallback(() => { window.location.replace(`#/search?q=${searchInputRef.current.value}`); }, []); @@ -32,23 +30,29 @@ const SearchBar = React.memo(({ className }) => { } }, [active, focusable]); return ( -