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

Fixed bug in AgGridModel.getExpandState() #3551

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@

### 🐞 Bug Fixes

* Specify `react-grid-layout` v1.4.3 to avoid breaking change to `DashCanvas` in v1.4.4
(see https://github.com/react-grid-layout/react-grid-layout/issues/1990)
* Fixed serialization and comparison of grid expand/collapse state, which was badly broken and could
trigger long browser waits for grids with > 2 levels of nesting and numeric record IDs.
* Fixed `UniqueAggregator` to properly check equality for `Date` fields.
* Pinned to `[email protected]` to avoid v1.4.4 bugs affecting `DashCanvas` interactions
(see https://github.com/react-grid-layout/react-grid-layout/issues/1990).

## 59.4.0 - 2023-11-28

### 💥 Breaking Changes

* The constructors for `ColumnGroup` no long accept arbitrary rest (e.g `...rest`)
arguments for applying app-specific data to the object. Instead, use the new `appData` property.
arguments for applying app-specific data to the object. Instead, use the new `appData` property.

### ⚙️ Technical

Expand Down
16 changes: 11 additions & 5 deletions cmp/ag-grid/AgGridModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
isEqual,
isNil,
partition,
set,
setWith,
startCase
} from 'lodash';
import {GridSorter, GridSorterLike} from '../grid/GridSorter';
Expand Down Expand Up @@ -466,8 +466,12 @@ export class AgGridModel extends HoistModel {
this._prevSortBy = sortBy;
}

/** @returns the current row expansion state of the grid in a serializable form. */
getExpandState(): any {
/**
* @returns the current row expansion state of the grid in a serializable form.
* Returned object has keys for StoreRecordIds of top-level, expanded records and values
* of either `true` or an object with keys of StoreRecordIds of expanded child records.
*/
getExpandState(): PlainObject {
this.throwIfNotReady();

const expandState = {};
Expand All @@ -486,8 +490,10 @@ export class AgGridModel extends HoistModel {
return;
}

// Note use of setWith + customizer - required to ensure that nested nodes are
// serialized as objects - see https://github.com/xh/hoist-react/issues/3550.
const path = this.getGroupNodePath(node);
set(expandState, path, true);
setWith(expandState, path, true, () => ({}));
}
});

Expand All @@ -498,7 +504,7 @@ export class AgGridModel extends HoistModel {
* Sets the grid row expansion state
* @param expandState - grid expand state retrieved via getExpandState()
*/
setExpandState(expandState: any) {
setExpandState(expandState: PlainObject) {
this.throwIfNotReady();

const {agApi} = this;
Expand Down
Loading