diff --git a/modules/app/components/filters/SearchBar.tsx b/modules/app/components/filters/SearchBar.tsx index b8ca90e20..38691631a 100644 --- a/modules/app/components/filters/SearchBar.tsx +++ b/modules/app/components/filters/SearchBar.tsx @@ -13,6 +13,12 @@ type Props = { export const SearchBar = ({ onChange, value, placeholder = 'Search', ...props }: Props): JSX.Element => { const [searchTerm, setSearchTerm] = useState(''); + useEffect(() => { + if (value) { + setSearchTerm(value); + } + }, []); + const handleInput = event => { setSearchTerm(event.target.value); debounce(onChange(event.target.value)); diff --git a/pages/polling.tsx b/pages/polling.tsx index 886a37267..356aba6ae 100644 --- a/pages/polling.tsx +++ b/pages/polling.tsx @@ -76,8 +76,15 @@ const getSortCriteria = (sort: PollsSortEnum | null) => { const PollingOverview = ({ polls, tags }: PollingPageData) => { const { trackButtonClick } = useAnalytics(ANALYTICS_PAGES.POLLING); - const [pollFilters, setCategoryFilter, resetPollFilters, sort] = useUiFiltersStore( - state => [state.pollFilters, state.setCategoryFilter, state.resetPollFilters, state.pollsSortBy], + const [pollFilters, setCategoryFilter, resetPollFilters, sort, title, setTitle] = useUiFiltersStore( + state => [ + state.pollFilters, + state.setCategoryFilter, + state.resetPollFilters, + state.pollsSortBy, + state.pollFilters.title, + state.setTitle + ], shallow ); const setFilteredPolls = usePollsStore(state => state.setFilteredPolls); @@ -157,8 +164,6 @@ const PollingOverview = ({ polls, tags }: PollingPageData) => { mutateAllUserVotes(); }, [addressToCheck]); - const [title, setTitle] = useUiFiltersStore(state => [state.pollFilters.title, state.setTitle], shallow); - return (