-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix browser nav & remove the need to double-ENTER on the searchbar #298
base: develop
Are you sure you want to change the base?
Changes from 11 commits
3832725
e9e6e10
57f4566
1ce794d
c93e6a9
673bbf4
11e2a2f
9dc3e06
17f3293
143f080
a782977
96afc30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,6 @@ interface SearchProps { | |
* | ||
* Styled for the splash page | ||
*/ | ||
let wasEmpty = false; // tracks if the searchbar was empty before the new entry (to create a new browser navigation entry push()) | ||
const SearchBar = ({ | ||
manageQuery, | ||
onSelect, | ||
|
@@ -73,25 +72,13 @@ const SearchBar = ({ | |
} else { | ||
delete newQuery.searchTerms; | ||
} | ||
if (wasEmpty) { | ||
// if the searchbar was cleared before this entry, | ||
router.push( | ||
{ | ||
query: router.query, | ||
}, | ||
undefined, | ||
{ shallow: true }, | ||
); | ||
wasEmpty = false; | ||
} //otherwise, just update the current navigation entry query | ||
else | ||
router.replace( | ||
{ | ||
query: newQuery, | ||
}, | ||
undefined, | ||
{ shallow: true }, | ||
); | ||
router.push( | ||
{ | ||
query: router.query, | ||
}, | ||
undefined, | ||
{ shallow: true }, | ||
); | ||
} | ||
} | ||
|
||
|
@@ -159,9 +146,6 @@ const SearchBar = ({ | |
|
||
//update parent and queries | ||
function onChange_internal(newValue: SearchQuery[]) { | ||
if (newValue.length == 0) { | ||
wasEmpty = true; // so that the next search creates a new navigation entry (push()) | ||
} | ||
if (manageQuery === 'onChange') { | ||
updateQueries(newValue); | ||
} | ||
|
@@ -181,6 +165,7 @@ const SearchBar = ({ | |
if (newValue.length) setErrorTooltip(false); //close the tooltip if there is at least 1 valid search term | ||
setValue(newValue); | ||
onChange_internal(newValue); | ||
onSelect_internal(newValue); // clicking enter to select a autocomplete suggestion triggers a new search (it also 'Enters' for the searchbar) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @TyHil Is this fine. setValue sets I wanted to pass in value, but that does not get updated in time ig for The other thing is there is a function Is it fine to have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I suppose if we can remove
TyHil marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
//update parent and queries | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I think we can remove this line since the new line below covers its functionality