Skip to content
Open
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
or disruptive action.
* Updated grid column filters to apply on `Enter` / dismiss on `Esc` and tweaked the filter popup
toolbar for clarity.
* `GridCountLabel` supports a new `excludeParents` property to exclude parent records from the
count. This is useful for tree grids, where the parent record count is not always relevant.

### 🐞 Bug Fixes

* Handled an edge-case `ViewManager` bug where `enableDefault` changed to `false` after some user
state had already been persisted w/users pointed at in-code default view. The manager now calls
its configured `initialViewSpec` function as expected in this case.

* `XH.restoreDefaultsAsync` will now clear basic view state. Views themselves will be preserved.
Requires hoist-core v31.2

Expand Down
15 changes: 13 additions & 2 deletions cmp/grid/helpers/GridCountLabel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ export interface GridCountLabelProps extends HoistProps, BoxProps {
*/
includeChildren?: boolean;

/**
* True to exclude parent records from the count.
* If false (default) parent records will be included in count.
* Ignored if `includeChildren` is false.
*/
excludeParents?: boolean;

/**
* Control display of selection count after overall records count: auto (default) to display
* count when greater than 1, or always/never to show/hide regardless of current count.
Expand All @@ -42,6 +49,7 @@ export const [GridCountLabel, gridCountLabel] = hoistCmp.withFactory<GridCountLa
render({
gridModel,
includeChildren = false,
excludeParents = false,
showSelectionCount = 'auto',
unit = 'record',
...props
Expand All @@ -60,8 +68,11 @@ export const [GridCountLabel, gridCountLabel] = hoistCmp.withFactory<GridCountLa

const fmtCount = count => fmtNumber(count, {precision: 0, asHtml: true}),
recCountString = () => {
const count = includeChildren ? store.count : store.rootCount,
unitLabel = count === 1 ? singularize(unit) : pluralize(unit);
let count = includeChildren ? store.count : store.rootCount;
if (excludeParents && includeChildren) {
count = store.records.filter(it => !it.children.length).length;
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This filtering operation on store.records is performed on every render when excludeParents and includeChildren are both true. Consider caching this calculation or using a memoized getter from the store to avoid repeated array filtering operations.

Copilot uses AI. Check for mistakes.

}
const unitLabel = count === 1 ? singularize(unit) : pluralize(unit);

return `${fmtCount(count)} ${unitLabel}`;
},
Expand Down
Loading