fix: DH-22976: control IrisGrid sorts and filters - #2737
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2737 +/- ##
==========================================
+ Coverage 51.39% 51.69% +0.30%
==========================================
Files 797 797
Lines 45887 45928 +41
Branches 11733 11942 +209
==========================================
+ Hits 23582 23744 +162
+ Misses 22286 22138 -148
- Partials 19 46 +27
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds controlled sorting and quick-filter behavior to IrisGrid, supporting the upcoming deephaven-plugins integration while preserving uncontrolled behavior.
Changes:
- Adds controlled-state flags and change callbacks.
- Synchronizes filter input text with external values.
- Adds controlled-state and input synchronization tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
IrisGrid.tsx |
Implements controlled sorts and quick filters. |
IrisGrid.test.tsx |
Tests controlled and uncontrolled behavior. |
FilterInputField.tsx |
Synchronizes external filter values. |
FilterInputField.test.tsx |
Tests external value synchronization. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
dgodinez-dh
left a comment
There was a problem hiding this comment.
The AI pointed this out, but it looks like applyInputFilters, rebuildFilters, and setFilters call setState on quickFilters. Also handleUpdateCustomColumns calls setState on quickFilters and sorts. I think this need to be requests.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (2)
packages/iris-grid/src/IrisGrid.tsx:1040
- Controlled state can still diverge after
rollback(): that method directly replacessortsandquickFiltersfromlastLoadedConfig(or clears them), then this condition and the quick-filter equivalent below skip resynchronization because the controlled prop references and flags did not change. A request failure or Cancel can therefore leave the grid/model different from its parent-owned values. The rollback path needs to preserve or explicitly propose controlled values instead of silently overwriting them.
if (
sorts !== prevProps.sorts ||
(!prevProps.isSortsControlled && isSortsControlled)
) {
this.updateSorts(sorts);
packages/iris-grid/src/IrisGrid.tsx:1841
- In controlled quick-filter mode,
didQuickFiltersChangecan be true even thoughrequestQuickFiltersChangedeliberately does not update state. The caller at lines 1018–1024 interprets this return value as an applied change and starts loading; if the parent omits or rejects the callback, no model request occurs to stop that loader. Report a change here only when quick filters were actually applied internally (advanced-filter changes should still return true).
return didQuickFiltersChange || didAdvancedFiltersChange;
with only advanced filters, there is no quick-filter change to trigger it
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
packages/iris-grid/src/IrisGrid.tsx:3036
- The controlled guard is bypassed by
rollback(), which still writes bothsortsandquickFiltersdirectly withsetState(lines 2570-2598). After a model request fails, the grid can therefore render a rolled-back value while the unchanged controlled props still contain the parent-owned value; reference checks incomponentDidUpdatewill not resynchronize it. Make rollback respect controlled ownership and notify/reconcile the parent so props and internal state cannot remain divergent.
requestSortsChange(sorts: readonly SortDescriptor[]): void {
const { isSortsControlled, onSortsChange } = this.props;
onSortsChange?.(sorts);
if (!isSortsControlled) {
this.updateSorts(sorts);
dgodinez-dh
left a comment
There was a problem hiding this comment.
Left one more comment.
Additionally, there are a lot of AI comments on this review. You should either address them or close them as not relevant.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (2)
packages/iris-grid/src/IrisGrid.tsx:305
- The new controlled-sort contract is bypassed by
rollback(): both rollback branches still assignstate.sortsdirectly. After a request failure or user cancellation, the grid can therefore display/apply rolled-back sorts while the unchanged controlledsortsprop still contains the parent-owned value, andcomponentDidUpdatewill not resynchronize it because the prop reference did not change. Rollback needs to preserve controlled ownership (for example, report the rollback value to the parent or define an explicit failure callback) rather than silently diverging.
isSortsControlled: boolean;
onSortsChange?: (sorts: readonly SortDescriptor[]) => void;
packages/iris-grid/src/IrisGrid.tsx:2118
rebuildFiltersis an internal regeneration of the existing conditions (for example after a time-zone or table change), not a user edit. Routing it through the controlled-change gate means a controlled grid does not installnewQuickFilters; with no change handler it also leaves the loading scrim started above even though the model will never receive a new filter. Apply the rebuilt map directly here so controlled filters are regenerated too.
this.requestQuickFiltersChange(newQuickFilters);
Adds controlled sorts and quick filters to IrisGrid. User changes are reported through callbacks without updating internal state, while uncontrolled behavior remains unchanged.
This PR should be merged and released before deephaven-plugins#1377.