Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(data-table): move ToolbarSearch filtering to DataTable for Svelte 5 compatibility #2037

Merged
merged 1 commit into from
Nov 10, 2024

Conversation

metonym
Copy link
Collaborator

@metonym metonym commented Nov 10, 2024

Fixes #2033

Svelte 5 exposes a bug when using DataTable and ToolbarSearch. Initial filtering might work, but original rows are not reset.

The root cause is a reset loop caused by ToolbarSearch. It currently reads and writes $tableRows, which is the source of truth used by DataTable.

One of the constraints is for filteredIds to be bindable to ToolbarSearch (but not two-way reactivity). Beyond that, ToolbarSearch should not need to read the source rows or manipulate them directly.

The solution is to move the filtering logic to the parent DataTable. A copy of the original rows is set (unless rows changes). Filtering will then filter on a subset of the copy without modifying the source.

@metonym metonym marked this pull request as ready for review November 10, 2024 17:26
@metonym metonym changed the title fix(data-table): handle ToolbarSearch filtering in DataTable fix(data-table): move ToolbarSearch filtering to DataTable for Svelte 5 compatibility Nov 10, 2024
@metonym metonym merged commit 3192824 into master Nov 10, 2024
3 checks passed
@metonym metonym deleted the data-table-filterable-svelte5 branch November 10, 2024 17:27
@metonym
Copy link
Collaborator Author

metonym commented Nov 20, 2024

Released in v0.86.0

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.

[Svelte 5] Filterable DataTable does not reset correctly
1 participant