Skip to content

fix: client-side filter cookie paths and clear functionality#2229

Merged
DonKoko merged 2 commits intomainfrom
2221-bug-filters-reset-after-editing-an-asset
Dec 3, 2025
Merged

fix: client-side filter cookie paths and clear functionality#2229
DonKoko merged 2 commits intomainfrom
2221-bug-filters-reset-after-editing-an-asset

Conversation

@DonKoko
Copy link
Copy Markdown
Contributor

@DonKoko DonKoko commented Dec 3, 2025

Fixed client-side cookie management to work correctly with RR7 single fetch by ensuring consistent root path usage and proper cookie removal.

Root cause: Client-side code was still using page-specific paths (/assets, /bookings, /kits) when writing/removing cookies, while server-side was updated to use root path (/). This caused cookies to be recreated at old paths, breaking filter persistence and clear functionality.

Changes:

  • Updated destroyCookieValues to always use root path (/) for consistency
  • Updated useCookieDestroy hook to use root path instead of determining path from current route
  • Fixed cookie removal to include same options (sameSite, secure) as cookie setting, as required by js-cookie library
  • Added legacy cookie cleanup when removing cookies to ensure old path-specific cookies are deleted
  • Fixed deleteKeysInSearchParams to batch all key deletions in a single setSearchParams call instead of multiple calls that triggered intermediate cookie states

This ensures:

  • Filter cookies work during client-side navigation in RR7 single fetch
  • Clear filters functionality works correctly in both simple and advanced modes
  • No stale cookies remain at old paths
  • Cookie updates are atomic (all-or-nothing) rather than incremental

Fixed client-side cookie management to work correctly with RR7 single
fetch by ensuring consistent root path usage and proper cookie removal.

Root cause: Client-side code was still using page-specific paths
(/assets, /bookings, /kits) when writing/removing cookies, while
server-side was updated to use root path (/). This caused cookies to be
recreated at old paths, breaking filter persistence and clear
functionality.

Changes:
- Updated destroyCookieValues to always use root path (/) for consistency
- Updated useCookieDestroy hook to use root path instead of determining
  path from current route
- Fixed cookie removal to include same options (sameSite, secure) as
  cookie setting, as required by js-cookie library
- Added legacy cookie cleanup when removing cookies to ensure old
  path-specific cookies are deleted
- Fixed deleteKeysInSearchParams to batch all key deletions in a single
  setSearchParams call instead of multiple calls that triggered
  intermediate cookie states

This ensures:
- Filter cookies work during client-side navigation in RR7 single fetch
- Clear filters functionality works correctly in both simple and advanced
  modes
- No stale cookies remain at old paths
- Cookie updates are atomic (all-or-nothing) rather than incremental
@vercel
Copy link
Copy Markdown

vercel bot commented Dec 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
shelf-docs Ignored Ignored Preview Dec 3, 2025 2:10pm

@DonKoko DonKoko merged commit 3be2278 into main Dec 3, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant