Skip to content

Commit e75caff

Browse files
committed
updates
1 parent 5015bd2 commit e75caff

File tree

13 files changed

+154
-63
lines changed

13 files changed

+154
-63
lines changed

public/Algolia-logo-blue.svg

Lines changed: 1 addition & 0 deletions
Loading

public/Algolia-logo-white.svg

Lines changed: 1 addition & 0 deletions
Loading

src/components/FeedPage.tsx

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,15 @@ export function FeedPage({
6363
const saved = localStorage.getItem('feedFilters')
6464
if (saved) {
6565
try {
66-
setSavedFilters(JSON.parse(saved))
66+
const parsed = JSON.parse(saved)
67+
// Convert null values back to undefined (they were nullified for JSON serialization)
68+
const restored = Object.fromEntries(
69+
Object.entries(parsed).map(([k, v]) => [
70+
k,
71+
v === null ? undefined : v,
72+
]),
73+
)
74+
setSavedFilters(restored as typeof search)
6775
} catch {
6876
// Ignore parse errors
6977
}
@@ -75,9 +83,11 @@ export function FeedPage({
7583
}
7684
}, [mounted])
7785

78-
// Merge saved filters with URL params (URL params take precedence)
86+
// Use search params directly - savedFilters is only used to restore preferences
87+
// when navigating back to the page (the filters are already in the URL from the
88+
// previous save). We only fall back to savedFilters for viewMode since that's
89+
// not always in the URL.
7990
const effectiveFilters = {
80-
...savedFilters,
8191
...search,
8292
viewMode:
8393
search.viewMode ??
@@ -156,9 +166,22 @@ export function FeedPage({
156166
})
157167

158168
// Save to localStorage
169+
// Note: JSON.stringify strips undefined values, so we need to explicitly
170+
// null out fields that are being cleared to overwrite saved values
159171
if (typeof window !== 'undefined') {
160-
const updatedFilters = { ...search, ...newFilters, page: 1 }
161-
localStorage.setItem('feedFilters', JSON.stringify(updatedFilters))
172+
const updatedFilters = {
173+
...search,
174+
...newFilters,
175+
page: 1,
176+
}
177+
// Convert undefined to null for JSON serialization, then back on parse
178+
const forStorage = Object.fromEntries(
179+
Object.entries(updatedFilters).map(([k, v]) => [
180+
k,
181+
v === undefined ? null : v,
182+
]),
183+
)
184+
localStorage.setItem('feedFilters', JSON.stringify(forStorage))
162185
setSavedFilters(updatedFilters)
163186
}
164187
}

src/components/FeedTopBarFilters.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export function FeedTopBarFilters({
7979

8080
React.useEffect(() => {
8181
onFiltersChange({ search: debouncedSearch || undefined })
82+
// eslint-disable-next-line react-hooks/exhaustive-deps
8283
}, [debouncedSearch])
8384

8485
React.useEffect(() => {

src/components/FilterComponents.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,21 @@ export function TopBarFilter({
4141
}: TopBarFilterProps) {
4242
const [mobileExpanded, setMobileExpanded] = useState(false)
4343

44+
// Separate AddFilterButton from other children (chips)
45+
const childArray = React.Children.toArray(children)
46+
const addFilterButton = childArray.find(
47+
(child) =>
48+
React.isValidElement(child) &&
49+
(child.type as { displayName?: string }).displayName ===
50+
'AddFilterButton',
51+
)
52+
const filterChips = childArray.filter(
53+
(child) =>
54+
!React.isValidElement(child) ||
55+
(child.type as { displayName?: string }).displayName !==
56+
'AddFilterButton',
57+
)
58+
4459
return (
4560
<div
4661
className={twMerge(
@@ -115,7 +130,8 @@ export function TopBarFilter({
115130
size="sm"
116131
/>
117132
)}
118-
{children}
133+
{addFilterButton}
134+
{filterChips}
119135
{hasActiveFilters && onClearAll && (
120136
<button
121137
onClick={onClearAll}

src/components/SearchModal.tsx

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -777,28 +777,18 @@ export function SearchModal() {
777777
href="https://www.algolia.com/developers/?utm_medium=referral&utm_content=powered_by&utm_source=tanstack.com&utm_campaign=docsearch"
778778
target="_blank"
779779
rel="noopener noreferrer"
780-
className="inline-flex items-center gap-1 hover:text-gray-600 dark:hover:text-gray-300 transition-colors"
780+
className="inline-flex items-center gap-1 hover:opacity-70 transition-opacity"
781781
>
782-
<svg
783-
width="77"
784-
height="19"
785-
aria-label="Algolia"
786-
className="h-4 w-auto"
787-
>
788-
<path
789-
d="M2.5067 0h14.0245c1.384 0 2.5066 1.1226 2.5066 2.5067V16.5c0 1.3775-1.1227 2.5-2.5066 2.5H2.5067C1.1226 19 0 17.8775 0 16.5V2.5067C0 1.1226 1.1226 0 2.5067 0z"
790-
fill="#5468FF"
791-
/>
792-
<path
793-
d="M9.5173 3.7573c-2.9477 0-5.3395 2.3883-5.3395 5.3315 0 2.9432 2.3918 5.3315 5.3395 5.3315 2.9478 0 5.3396-2.3883 5.3396-5.3315 0-2.9432-2.3918-5.3315-5.3396-5.3315zm0 8.9448c-1.993 0-3.6113-1.6148-3.6113-3.6133 0-1.9984 1.6183-3.6133 3.6113-3.6133 1.993 0 3.6113 1.6149 3.6113 3.6133 0 1.9985-1.6183 3.6133-3.6113 3.6133zm0-6.3423c-1.5019 0-2.7234 1.2193-2.7234 2.729 0 1.5095 1.2215 2.7289 2.7234 2.7289 1.5019 0 2.7234-1.2194 2.7234-2.7289 0-1.5097-1.2215-2.729-2.7234-2.729zm0 4.5761c-1.0148 0-1.8395-.823-1.8395-1.8471 0-1.0242.8247-1.8472 1.8395-1.8472 1.0148 0 1.8395.823 1.8395 1.8472 0 1.024-.8247 1.8471-1.8395 1.8471zm0-3.0107c-.6378 0-1.1556.517-1.1556 1.1636 0 .6465.5178 1.1636 1.1556 1.1636.6378 0 1.1556-.5171 1.1556-1.1636 0-.6466-.5178-1.1636-1.1556-1.1636zM9.5173 3.7573v1.7283m0-1.7283c-2.9477 0-5.3395 2.3883-5.3395 5.3315m5.3395-5.3315c2.9478 0 5.3396 2.3883 5.3396 5.3315m-5.3396 3.6133c1.993 0 3.6113-1.6148 3.6113-3.6133m-3.6113 3.6133c-1.993 0-3.6113-1.6148-3.6113-3.6133m7.2226 0c0 1.9985-1.6183 3.6133-3.6113 3.6133m3.6113-3.6133c0-1.9984-1.6183-3.6133-3.6113-3.6133m0 0c1.5019 0 2.7234 1.2193 2.7234 2.729m-2.7234-2.729c-1.5019 0-2.7234 1.2193-2.7234 2.729m5.4468 0c0 1.5095-1.2215 2.7289-2.7234 2.7289m2.7234-2.7289c0-1.5097-1.2215-2.729-2.7234-2.729m0 4.5761c-1.5019 0-2.7234-1.2194-2.7234-2.7289m2.7234 2.7289c1.0148 0 1.8395-.823 1.8395-1.8471m-1.8395 1.8471c-1.0148 0-1.8395-.823-1.8395-1.8471m3.679 0c0 1.024-.8247 1.8471-1.8395 1.8471m1.8395-1.8471c0-1.0242-.8247-1.8472-1.8395-1.8472m0 3.6943c-.6378 0-1.1556-.5171-1.1556-1.1636m1.1556 1.1636c.6378 0 1.1556-.5171 1.1556-1.1636m-2.3112 0c0 .6465.5178 1.1636 1.1556 1.1636m-1.1556-1.1636c0-.6466.5178-1.1636 1.1556-1.1636m1.1556 1.1636c0-.6466-.5178-1.1636-1.1556-1.1636"
794-
fill="#FFF"
795-
fillRule="evenodd"
796-
/>
797-
<path
798-
d="M35.143 10.857h-1.88l-.294-.504a3.37 3.37 0 01-1.792.504c-1.596 0-2.989-1.169-2.989-2.989 0-1.82 1.393-2.989 2.989-2.989.798 0 1.533.252 2.03.644v-.476h1.936v5.81zm-2.989-4.272c-.728 0-1.26.476-1.26 1.283 0 .812.532 1.288 1.26 1.288.728 0 1.26-.476 1.26-1.288 0-.807-.532-1.283-1.26-1.283zM39.223 2.95v7.907H37.28V2.95h1.943zM47.556 10.766c0 .056-.007.091-.007.091h-4.566c.084.448.476.798 1.12.798.476 0 .826-.168 1.022-.448l1.582.924c-.518.728-1.386 1.148-2.604 1.148-1.848 0-3.108-1.232-3.108-2.933 0-1.701 1.26-2.94 3.108-2.94 1.75 0 2.933 1.148 3.108 2.758.028.168.049.336.042.504.007.035.007.07.007.098h-.704zm-1.932-1.064c-.084-.462-.476-.826-1.127-.826-.651 0-1.043.364-1.127.826h2.254zM53.576 10.857h-1.944V7.672c0-.686-.42-1.008-.952-1.008-.532 0-.952.322-.952 1.008v3.185h-1.944V5.048h1.944v.476c.49-.392 1.19-.644 1.96-.644 1.4 0 2.394.91 2.394 2.394v3.583h-.506zM55.877 5.048h1.944v5.81h-1.944v-5.81zm.966-2.16c.644 0 1.176.525 1.176 1.176 0 .644-.532 1.176-1.176 1.176-.644 0-1.176-.532-1.176-1.176 0-.651.532-1.176 1.176-1.176zM64.883 10.857h-1.88l-.294-.504a3.37 3.37 0 01-1.792.504c-1.596 0-2.989-1.169-2.989-2.989 0-1.82 1.393-2.989 2.989-2.989.798 0 1.533.252 2.03.644v-.476H64.883v5.81zm-2.989-4.272c-.728 0-1.26.476-1.26 1.283 0 .812.532 1.288 1.26 1.288.728 0 1.26-.476 1.26-1.288 0-.807-.532-1.283-1.26-1.283z"
799-
fill="currentColor"
800-
/>
801-
</svg>
782+
<img
783+
src="/Algolia-logo-blue.svg"
784+
alt="Algolia"
785+
className="h-4 w-auto dark:hidden"
786+
/>
787+
<img
788+
src="/Algolia-logo-white.svg"
789+
alt="Algolia"
790+
className="h-4 w-auto hidden dark:block"
791+
/>
802792
</a>
803793
</div>
804794
</SearchFiltersProvider>

0 commit comments

Comments
 (0)