Skip to content

fix: invalidate stale permalink state when listContextParams changes#6

Merged
aboodman merged 1 commit intomainfrom
fix/invalidate-stale-permalink-state
Feb 28, 2026
Merged

fix: invalidate stale permalink state when listContextParams changes#6
aboodman merged 1 commit intomainfrom
fix/invalidate-stale-permalink-state

Conversation

@aboodman
Copy link
Contributor

@aboodman aboodman commented Feb 28, 2026

Summary

When using scroll position restoration with permalinkState, the saved state would be restored even if the list context had changed (e.g., after clearing a search filter). This caused the virtualizer to restore an incorrect scroll position for the new list.

Changes:

  • Adds required listContextParams field to PermalinkHistoryState type
  • Computes effectivePermalinkState that returns null if saved context doesn't match current (by identity)
  • Includes listContextParams when saving state via onPermalinkStateChange

Test plan

  • Manually tested in ztunes app:
    1. Scroll down in list
    2. Apply search filter (list resets to top)
    3. Navigate away and back - scroll position not restored (correct)
    4. Navigate away and back without changing filter - scroll position restored (correct)

@aboodman aboodman requested a review from arv February 28, 2026 21:23
@aboodman aboodman force-pushed the fix/invalidate-stale-permalink-state branch from 56e53bb to 5aaadea Compare February 28, 2026 21:24
When using scroll position restoration with permalinkState, the saved
state would be restored even if the list context had changed (e.g.,
after clearing a search filter). This caused the virtualizer to restore
an incorrect scroll position for the new list.

This change:
- Adds optional listContextParams to PermalinkHistoryState type
- Computes effectivePermalinkState that returns null if saved context
  doesn't match current context (using JSON.stringify for deep equality)
- Uses effectivePermalinkState instead of permalinkState for restoration
- Includes listContextParams when saving state via onPermalinkStateChange

Backwards compatible: if no listContextParams was saved, the state is
used as-is.
@aboodman aboodman force-pushed the fix/invalidate-stale-permalink-state branch from 5aaadea to 3c35776 Compare February 28, 2026 21:26
@aboodman aboodman merged commit aac667c into main Feb 28, 2026
2 checks passed
@aboodman aboodman deleted the fix/invalidate-stale-permalink-state branch February 28, 2026 21:29
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