From f42ca6a10357e4ea95579002ad5c9b27b2cacce0 Mon Sep 17 00:00:00 2001 From: leonardosfl Date: Fri, 7 Aug 2020 09:32:47 -0300 Subject: [PATCH] Fix query being reset when selecting a filter Also fix issue where default query would not be applied when using filters (because location.search would not be empty) --- src/components/dashboard.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/dashboard.js b/src/components/dashboard.js index bfd3bcf..5ee97b3 100644 --- a/src/components/dashboard.js +++ b/src/components/dashboard.js @@ -53,7 +53,7 @@ export default function Dashboard() { const params = new URLSearchParams(location.search); useEffect(() => { - if (location.search === "") { + if (!params.get('q')) { history.replace({ search: createPreprintQs({ text: covidTerms }, location.search) }); } }, [apiQs]); @@ -190,7 +190,7 @@ export default function Dashboard() { onChange={e => { const search = createPreprintQs( { - text: covidTerms, + text: params.getAll('q'), hasOthersRec: e.target.checked || null }, location.search @@ -217,7 +217,7 @@ export default function Dashboard() { onChange={e => { const search = createPreprintQs( { - text: covidTerms, + text: params.getAll('q'), hasPeerRec: e.target.checked || null }, location.search @@ -244,7 +244,7 @@ export default function Dashboard() { onChange={e => { const search = createPreprintQs( { - text: covidTerms, + text: params.getAll('q'), hasData: e.target.checked || null }, location.search @@ -271,7 +271,7 @@ export default function Dashboard() { onChange={e => { const search = createPreprintQs( { - text: covidTerms, + text: params.getAll('q'), hasCode: e.target.checked || null }, location.search @@ -299,7 +299,7 @@ export default function Dashboard() { ) => { const search = createPreprintQs( { - text: covidTerms, + text: params.getAll('q'), sort: nextSortOption }, location.search