Skip to content

fix(data-table): preserve active filter when rows prop changes#2944

Merged
metonym merged 1 commit intomasterfrom
preserve-filter-on-rows-change
May 9, 2026
Merged

fix(data-table): preserve active filter when rows prop changes#2944
metonym merged 1 commit intomasterfrom
preserve-filter-on-rows-change

Conversation

@metonym
Copy link
Copy Markdown
Collaborator

@metonym metonym commented May 9, 2026

When ToolbarSearch (or any consumer) calls filterRows, the visible rows are stored in $tableRows while originalRows keeps the full set. As soon as the parent re-assigns rows (e.g. after a fetch), the reactive resets originalRows = [...rows]; $tableRows = rows; and the user's search is wiped without warning, even though the search input still shows the query.

The fix is to track the last filterRows inputs and replay them when rows is reassigned, so consumers calling filterRows via context don't silently lose the filter on row updates.

Svelte REPL repro: https://svelte.dev/playground/a43647f2061240ec9ef6b4852b15ca95?version=latest

@metonym metonym force-pushed the preserve-filter-on-rows-change branch from 0d2c94c to ee8432d Compare May 9, 2026 22:10
@metonym metonym force-pushed the preserve-filter-on-rows-change branch from ee8432d to f8326be Compare May 9, 2026 22:15
@metonym metonym merged commit fd4e9f6 into master May 9, 2026
11 checks passed
@metonym metonym deleted the preserve-filter-on-rows-change branch May 9, 2026 22:21
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