-
Notifications
You must be signed in to change notification settings - Fork 3
Fix Total Row Count on Grid #1726
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/components/Grid/Toolbar.tsx(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/components/Grid/Toolbar.tsx (3)
src/common/types.ts (1)
ChildrenProp(10-12)src/common/sx.ts (1)
StyleProps(5-8)src/components/Formatters/useNumberFormatter.tsx (1)
FormattedNumber(17-20)
🔇 Additional comments (1)
src/components/Grid/Toolbar.tsx (1)
46-48: Always display “0” when there are no rowsCurrently in
src/components/Grid/Toolbar.tsx(lines 46–48) the JSX<Typography minWidth={100}> Total Rows: {displayCount && <FormattedNumber value={displayCount} />} </Typography>uses a short-circuit that suppresses rendering when
displayCountis0, leaving the label blank. We should always render the formatted number so that “0” appears for zero rows.Apply this change:
- <Typography minWidth={100}> - Total Rows: {displayCount && <FormattedNumber value={displayCount} />} - </Typography> + <Typography minWidth={100}> + Total Rows: <FormattedNumber value={displayCount} /> + </Typography>Verified behavior:
- No filters → shows total row count
- Quick filter applied → shows filtered count
- Zero matching rows → correctly displays “0”
4fe7d53 to
bf2fbb7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/components/Grid/Toolbar.tsx (1)
22-28: Count logic misses quick filter and can be undefined; also doesn’t respect server-side filtering.
- Quick filter (quickFilterValues) isn’t considered, so filtered count can be skipped.
- When rowCount is undefined (common client-side), displayCount becomes undefined.
- Prefer gating on filterMode: for server-side filtering, rely on rowCount.
Apply this diff to handle all cases and ensure a safe fallback:
- const displayCount = useMemo(() => { - const { items } = filterModel; - const hasFilters = items.length > 0; - const count = hasFilters ? filteredRowIds.length : rootProps.rowCount; - - return count; - }, [filterModel, filteredRowIds.length, rootProps.rowCount]); + const displayCount = useMemo(() => { + const hasFilters = + (filterModel?.items?.length ?? 0) > 0 || + (filterModel?.quickFilterValues?.length ?? 0) > 0; + const isServer = rootProps.filterMode === 'server'; + + if (isServer) { + // Rely on server-provided total; fall back to rendered rows if absent. + return rootProps.rowCount ?? filteredRowIds.length; + } + + // Client-side: show filtered count when any filter is active; otherwise total rows. + return hasFilters + ? filteredRowIds.length + : (rootProps.rowCount ?? filteredRowIds.length); + }, [filterModel, filteredRowIds.length, rootProps.rowCount, rootProps.filterMode]);
🧹 Nitpick comments (1)
src/components/Grid/Toolbar.tsx (1)
49-50: Optional: extract “Total Rows” to i18n.If the app is localized elsewhere, move this string to your translation layer.
I can submit a follow-up patch wiring this through your i18n util if you share the convention (e.g., t('grid.totalRows')).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/components/Grid/Toolbar.tsx(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/components/Grid/Toolbar.tsx (3)
src/common/types.ts (1)
ChildrenProp(10-12)src/common/sx.ts (1)
StyleProps(5-8)src/components/Formatters/useNumberFormatter.tsx (1)
FormattedNumber(17-20)
🔇 Additional comments (2)
src/components/Grid/Toolbar.tsx (2)
2-9: Good move: derive grid state via selectors (imports look correct).Using the Pro selectors and hooks sets you up to compute counts accurately from live grid state.
15-21: LGTM: reading filter model and filtered row IDs from state (not props).This addresses uncontrolled/quick-filter cases that props can miss.
bf2fbb7 to
a8bdf9e
Compare
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/components/Grid/useDataGridSource.tsx (2)
252-253: Account for quick filter inhasFilter(otherwise toolbar count stays unfiltered when only quick filter is used)
hasFilteronly checksfilterModel.items. If a user applies the Quick Filter (toolbar search),itemscan be empty whilequickFilterValuesis populated. In that case, the updatedrowCountlogic won’t switch torows.length, and the toolbar will still show the unfiltered total.Recommend including quick filter detection:
- const hasFilter = !!view.filterModel && view.filterModel.items.length > 0; + const hasFilter = + !!view.filterModel && + ((view.filterModel.items?.length ?? 0) > 0 || + (view.filterModel.quickFilterValues?.length ?? 0) > 0);
436-439: Optionally alignpaginationModewithrowCountcondition to avoid any future warnings if pagination UI is re-enabledRight now
paginationModeis set based ontotal != null. SincerowCountswitches torows.lengthonly whenhasFilter && isCacheComplete, you could mirror that inpaginationModeto keep modes consistent (especially if footer pagination is ever shown again). Not strictly necessary today withhideFooterPagination, but makes intent clearer.- paginationMode: total != null ? 'server' : 'client', // Not used, but prevents row count warning. + // Align with rowCount condition; still prevents row count warnings if pagination UI returns. + paginationMode: + hasFilter && isCacheComplete + ? 'client' + : total != null + ? 'server' + : 'client',
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/components/Grid/useDataGridSource.tsx(1 hunks)
🔇 Additional comments (1)
src/components/Grid/useDataGridSource.tsx (1)
429-429: Fix aligns toolbar count with client-side filtering when cache is complete — LGTMUsing
rows.lengthforrowCountwhen a filter is active and the cache is complete matches the displayed data and avoids overstating totals. This should resolve the toolbar mismatch without affecting server-side pagination scenarios.
This fixes the total row count for Grid Toolbar, which was not accounting for client side filtering.