fix: expression property setters replace state instead of being additive#60
Merged
rkaraivanov merged 4 commits intomasterfrom Apr 1, 2026
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix filtering and sorting expressions not removing previous state
fix: expression property setters replace state instead of being additive
Mar 31, 2026
There was a problem hiding this comment.
Pull request overview
Fixes sortingExpressions / filterExpressions property setters so late-bound assignments replace existing sort/filter state (including correct clearing behavior when assigning an empty array), rather than merging with prior state.
Changes:
- Update
sortingExpressionsandfilterExpressionssetters to clear existing state before applying new expressions after initial render. - Ensure empty-array assignments clear all active expressions and still trigger the data pipeline update.
- Add tests covering replacement and clearing behavior for both sorting and filtering setters.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/components/grid.ts |
Resets sort/filter state inside expression setters; removes empty-array guard in filter() to ensure pipeline updates on clears. |
test/grid.properties.test.ts |
Adds 4 tests validating late-bound replacement and clearing for sort/filter expression setters. |
Comments suppressed due to low confidence (1)
src/components/grid.ts:252
- In the pre-render path (
!hasUpdated), the setter writes expressions directly intosorting.statewithout applying theSortControllerrule thatdirection: 'none'should remove the expression. SinceSortDataOperation.orderByhas no entry for'none', allowing'none'into the sort state can cause a runtime error during pipeline sorting (orderBy.get(direction)!becomes undefined). Consider mirroringSortController.#setExpressionhere (delete when direction is'none') or routing through controller logic that enforces this invariant.
} else {
for (const expr of expressions) {
this._stateController.sorting.state.set(expr.key, { ...expr });
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rkaraivanov
approved these changes
Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Setting
sortingExpressionsorfilterExpressionsafter initialization delegated to the additivesort()/filter()methods, causing new assignments to merge with existing state rather than replace it. Empty array assignment was also a no-op due to anexpressions.lengthguard.Changes
sortingExpressions/filterExpressionssetters: Clear existing state viareset()before applying new expressions when the component has already renderedTests
Added 4 tests covering replacement and clearing behavior for both sorting and filtering expression setters.