Skip to content

Commit

Permalink
Fix row group expanded.
Browse files Browse the repository at this point in the history
  • Loading branch information
bosskmk committed Mar 6, 2023
1 parent a244b80 commit f75bcae
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/src/manager/state/row_group_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ mixin RowGroupState implements IPlutoGridState {
refRows.removeWhereFromOriginal(isNotMainGroupedRow);
}

void _restoreExpandedRowGroup() {
void _restoreExpandedRowGroup({bool resetCurrentState = false}) {
final Iterable<PlutoRow> expandedRows = refRows.filterOrOriginalList
.where(isExpandedGroupedRow)
.toList(growable: false);
Expand All @@ -655,7 +655,7 @@ mixin RowGroupState implements IPlutoGridState {
}

if (toResetPage) {
resetPage(resetCurrentState: false, notify: false);
resetPage(resetCurrentState: resetCurrentState, notify: false);
}
}

Expand Down Expand Up @@ -706,7 +706,9 @@ mixin RowGroupState implements IPlutoGridState {

refRows.addAll(rows);

if (isPaginated) {
if (enabledRowGroups) {
_restoreExpandedRowGroup(resetCurrentState: true);
} else if (isPaginated) {
resetPage(resetCurrentState: true, notify: false);
}
}
Expand Down
48 changes: 48 additions & 0 deletions test/scenario/grouping_rows/rendering_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,54 @@ void main() {
}
},
);

testWidgets('B 행을 expanded : true 로 설정 하면 자식이 렌더링 되어야 한다.', (tester) async {
rows[1].type.group.setExpanded(true);

await buildGrid(
tester: tester,
columns: columns,
rows: rows,
delegate: PlutoRowGroupTreeDelegate(
resolveColumnDepth: (column) =>
int.parse(column.field.replaceAll('column', '')) - 1,
showText: (cell) => true,
showFirstExpandableIcon: true,
),
);

expect(find.text('B1'), findsOneWidget);
expect(find.text('B2'), findsOneWidget);
expect(find.text('B3'), findsOneWidget);
expect(find.text('B4'), findsOneWidget);
});

testWidgets('B, B4 행을 expanded : true 로 설정 하면 자식이 렌더링 되어야 한다.',
(tester) async {
rows[1].type.group.setExpanded(true);
rows[1].type.group.children[3].type.group.setExpanded(true);

await buildGrid(
tester: tester,
columns: columns,
rows: rows,
delegate: PlutoRowGroupTreeDelegate(
resolveColumnDepth: (column) =>
int.parse(column.field.replaceAll('column', '')) - 1,
showText: (cell) => true,
showFirstExpandableIcon: true,
),
);

expect(find.text('B1'), findsOneWidget);
expect(find.text('B2'), findsOneWidget);
expect(find.text('B3'), findsOneWidget);
expect(find.text('B4'), findsOneWidget);

expect(find.text('B41'), findsOneWidget);
expect(find.text('B42'), findsOneWidget);
expect(find.text('B43'), findsOneWidget);
});
});

group('PlutoRowGroupByColumnDelegate - 2개 컬럼으로 그룹핑.', () {
Expand Down

0 comments on commit f75bcae

Please sign in to comment.