diff --git a/apps/portal/src/components/questions/QuestionSearchBar.tsx b/apps/portal/src/components/questions/QuestionSearchBar.tsx
index a27f043b..d57c8a48 100644
--- a/apps/portal/src/components/questions/QuestionSearchBar.tsx
+++ b/apps/portal/src/components/questions/QuestionSearchBar.tsx
@@ -46,13 +46,15 @@ export default function QuestionSearchBar<
value={sortValue}
onChange={onSortChange}
/>
-
+
+
+
);
}
diff --git a/apps/portal/src/pages/questions/index.tsx b/apps/portal/src/pages/questions/index.tsx
index d7558bb0..d77a96f2 100644
--- a/apps/portal/src/pages/questions/index.tsx
+++ b/apps/portal/src/pages/questions/index.tsx
@@ -143,19 +143,38 @@ export default function QuestionsHomePage() {
]);
useEffect(() => {
- if (areFiltersInitialized) {
+ if (areFiltersInitialized && !loaded) {
+ // Update query params
+ router.replace({
+ pathname: router.pathname,
+ query: {
+ companies: selectedCompanies,
+ locations: selectedLocations,
+ questionAge: selectedQuestionAge,
+ questionTypes: selectedQuestionTypes,
+ },
+ });
const hasFilter =
- router.query.companies ||
- router.query.questionTypes ||
- router.query.questionAge ||
- router.query.locations;
+ selectedCompanies.length > 0 ||
+ selectedLocations.length > 0 ||
+ selectedQuestionAge !== 'all' ||
+ selectedQuestionTypes.length > 0;
if (hasFilter) {
setHasLanded(true);
}
- // Console.log('landed', hasLanded);
+
setLoaded(true);
}
- }, [areFiltersInitialized, hasLanded, router.query]);
+ }, [
+ areFiltersInitialized,
+ hasLanded,
+ loaded,
+ router,
+ selectedCompanies,
+ selectedLocations,
+ selectedQuestionAge,
+ selectedQuestionTypes,
+ ]);
if (!loaded) {
return null;
@@ -291,7 +310,7 @@ export default function QuestionsHomePage() {
Filter by
{filterSidebar}
-
+
(
if (localStorageValue !== null) {
const loadedFilters = JSON.parse(localStorageValue);
setFilters(loadedFilters);
- router.replace({
- pathname: router.pathname,
- query: {
- ...router.query,
- [name]: loadedFilters,
- },
- });
}
}
setIsInitialized(true);