Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Commit

Permalink
Fix query being reset when selecting a filter
Browse files Browse the repository at this point in the history
Also fix issue where default query would not be applied when using filters (because location.search would not be empty)
  • Loading branch information
leonardosfl committed Aug 7, 2020
1 parent 154fa57 commit f42ca6a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/components/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -299,7 +299,7 @@ export default function Dashboard() {
) => {
const search = createPreprintQs(
{
text: covidTerms,
text: params.getAll('q'),
sort: nextSortOption
},
location.search
Expand Down

0 comments on commit f42ca6a

Please sign in to comment.