diff --git a/src/components/common/SearchBar/searchBar.tsx b/src/components/common/SearchBar/searchBar.tsx index 5499fe80..118171b4 100644 --- a/src/components/common/SearchBar/searchBar.tsx +++ b/src/components/common/SearchBar/searchBar.tsx @@ -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) } //update parent and queries diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index d0ddd218..f8a4c2d0 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -112,6 +112,7 @@ function MyApp({ Component, pageProps }: AppProps) { UTD Trends + - - { ); } + let pageTitle = ''; + courses.map((term) => { + pageTitle += searchQueryLabel(term) + ', '; + }); + professors.map((term) => { + pageTitle += searchQueryLabel(term) + ', '; + }); + pageTitle = + pageTitle.lastIndexOf(', ') === pageTitle.length - 2 + ? pageTitle.substring(0, pageTitle.lastIndexOf(', ')) + ' - ' + : pageTitle; + /* Final page */ return ( <> - Results - UTD Trends + {'Results - ' + pageTitle + 'UTD TRENDS'} + decodeSearchQueryLabel(el)) + .join(', ') + + 'UTD TRENDS' + } + />