Skip to content

Commit 3f2cfeb

Browse files
committed
Refactor filter modal logic in profiles-home: replace openFiltersModal with openDockedFilters and openFiltersSlideOver for persistent state and better desktop/mobile handling.
1 parent 9bf1d1b commit 3f2cfeb

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎web/components/profiles/profiles-home.tsx‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ export function ProfilesHome() {
9898
'profiles-home-show-early-banner',
9999
7 * DAY_MS,
100100
)
101-
const [openFiltersModal, setOpenFiltersModal] = useState(false)
102101
const [highlightFilters, setHighlightFilters] = useState(false)
103102
const [highlightSort, setHighlightSort] = useState(false)
104103
const searchInputRef = useRef<HTMLInputElement>(null)
@@ -115,6 +114,16 @@ export function ProfilesHome() {
115114
mql.addEventListener('change', update)
116115
return () => mql.removeEventListener('change', update)
117116
}, [])
117+
// Remembered across visits so people who browse with the filters open get them back.
118+
// Desktop only: on mobile the panel is a full-screen slide-over, and restoring that on
119+
// load would hide the grid behind a modal, so there it stays session state.
120+
const [openDockedFilters, setOpenDockedFilters] = usePersistentLocalState<boolean>(
121+
false,
122+
'profiles-filters-open',
123+
)
124+
const [openFiltersSlideOver, setOpenFiltersSlideOver] = useState(false)
125+
const openFiltersModal = isDesktop ? openDockedFilters : openFiltersSlideOver
126+
const setOpenFiltersModal = isDesktop ? setOpenDockedFilters : setOpenFiltersSlideOver
118127
const [sendScrollWarning, setSendScrollWarning] = useState(true)
119128
const [recentlyHiddenIds, setRecentlyHiddenIds] = useState<string[]>([])
120129
const {refreshHiddenProfiles} = useHiddenProfiles()

0 commit comments

Comments
 (0)