Skip to content

Conversation

@rdonigian
Copy link
Contributor

This fixes the total row count for Grid Toolbar, which was not accounting for client side filtering.

@rdonigian rdonigian requested a review from CarsonF as a code owner August 20, 2025 21:06
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 482f2b7 and 4fe7d53.

📒 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 rows

Currently 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 displayCount is 0, 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”

@rdonigian rdonigian force-pushed the fix-total-row-count branch from 4fe7d53 to bf2fbb7 Compare August 20, 2025 21:25
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 4fe7d53 and bf2fbb7.

📒 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.

@rdonigian rdonigian force-pushed the fix-total-row-count branch from bf2fbb7 to a8bdf9e Compare August 21, 2025 13:55
@SeedCompany SeedCompany deleted a comment from coderabbitai bot Aug 21, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 21, 2025

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{"name":"HttpError","status":404,"request":{"method":"PATCH","url":"https://api.github.com/repos/SeedCompany/cord-field/issues/comments/3208105048","headers":{"accept":"application/vnd.github.v3+json","user-agent":"octokit.js/0.0.0-development octokit-core.js/7.0.3 Node.js/24","authorization":"token [REDACTED]","content-type":"application/json; charset=utf-8"},"body":{"body":"<!-- This is an auto-generated comment: summarize by coderabbit.ai -->\n<!-- walkthrough_start -->\n\n<details>\n<summary>📝 Walkthrough</summary>\n\n## Walkthrough\nAdjusted rowCount computation in the data grid source hook: when a filter is active and the cache is complete, rowCount uses the length of currently loaded rows; otherwise it continues to use the total count.\n\n## Changes\n| Cohort / File(s) | Change Summary |\n|---|---|\n| **Data grid row count logic**<br>`src/components/Grid/useDataGridSource.tsx` | Modified rowCount to use rows.length when hasFilter and isCacheComplete are true; otherwise use total. No other logic changes. |\n\n## Estimated code review effort\n🎯 2 (Simple) | ⏱️ ~10 minutes\n\n</details>\n\n<!-- walkthrough_end -->\n\n<!-- announcements_start -->\n\n> [!TIP]\n> <details>\n> <summary>🔌 Remote MCP (Model Context Protocol) integration is now available!</summary>\n> \n> Pro plan users can now connect to remote MCP servers from the [Integrations](https://app.coderabbit.ai/integrations) page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.\n> \n> </details>\n\n<!-- announcements_end -->\n<!-- internal state start -->\n\n\n<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKPR1AGxJcAYvAAeMPi4aB6QNvgA7pAAwvjYGLj8WADiFPD0kAYAco4ClFwAjADsAEwAbJBZAKo2ADJcsLi43IgcAPTtROqw2AIaTMztAMokdHHM3Jiy7UwUtGAAZvAkHrTt3NgeHu0lFVUG1YgFkPP4GPDdmAfD8RQMJJACVBgMsFzL/mAEIR5gFFEwEwEkkstBnKQks9MG8uEopB58NwbiFcNg2vxuGQDjYSBIVpFKBiYs5EOcfAc6ipVhisjEKCRqHR0JxIKUAAylACsYHZAA4wBzoKVChx2eUxVyAFpGAAi0gY6W44nOXDgqE+0kguFgjx+oVOUQUIMgi3wfDSGSC+A8AmcABpIJEEG8nWhkBhgugGMDEvAMERTebGB4Vol7BlHssPDR0gGNOZLNVuLQmfRBCIxJItQ4nC5E9Y7LnmM5XAZ3LgvL4AkFfuEjXETedIJbMjk8ic9pUavVGs1Wh0uj0+gMWCMxrQJlMMDM5gtlqt1pttrsyt3DscKFwzhcrlgsrdsPdHtDXu9TQFvsFQv9Ab7QeWISQoS9YZB4askSjqOiuEjsVkuL4iQhIUMSpLkpS1IeBiAAUnrkDwAL4kotAAJQHPSjI0PQ1BcBy3K8gKQoimKErstKcoKkqKoYGquo8FsYQMgAjtg0hJJqyA6nq17MUa97vkg3AeGgsjMnI2oMa21q2g6TourASF4vA8SIB48i0FanpJGgPrxOGZp8AwobsGAiCRheMaUP6RAJgY+jGOAUBkOmiw4AQxBkMoOEKKw7BcLw/DCKI4hSDI8hMEoVCqOoWg6I5JhQOqyCoNcaB4IQpDkFQvmDGwiTbmg0TFqWTyRYoyixZo2i6GAhhOaYBiIPcswsNw5zsIg7Stu06IkLK1BoK2h7HhouCIP4HAGAARHNBgWJAACCACSXk5Wm9iOCWLj8O5byYKQiBGFAAKRI24YMKEDBbNQqlYAdAbMosALMJA6K2dqfFfegCgYFptGhNuUQXVCogsFqZ2IBoXgBjqCnYmgVmxigyB6WFjywbA7p+NZFAYZg9A8YwekMaggwic+mNICSbwkFOXg0GhADc/A8RQkRII86inCQJb+txfEaDACDcSs3EMUQ6S0IAmATIAyHUUL5Z3GuGBBSY86PYAaiJoKhhqRMgCTRcjlB0I6ixMZFpPMogDwYM4qmII6zrwF4ymbviAYa8p+JqV9vxgHaxz0Pk2N+3wwS6hzXPC9k+Bs9HkCIt0DCMNjT3Q0YBZLXjd3nILPtKCZzj5xgyD4O5JD+IrvnBpsAihmn7DqOLJ2QPH6eHVq6vV7XdAbH0TeQC3uDyBZRAO2iDJZwYACiiDiCWeWVbzwHRCQixGayACydDwI4s3zQ59WNS5/17R5WXeblzL5QFpzFVtebyJJUVVWoNUJafSV+cw6gAH0MiIAAQydedAAGL2cEkRyBhf4ABZFgkGKLQLkABmco5RigkAAJwCD5IUco7IkEkDQfA/kaASACAYMUHBXISClAEEgwoDBSj0ESs5J4ixSiLFUMURBFRuR0HKBgugAgUECFoIUWgOCcHYKwcURRaDijsnZHVQwv80B8kkYsHBDDSg4PKCwvkdC+SlDQFyRYtBygMBweY4oJiKJcgEOUHB8CyhcnUWfP+gDgGgJUiBCBrkvG/2YAwbgACmCJGrrgSBIQlZeIMAAbwMFUGaV0phqFDOIaQwxtqlhmlwGancd4xCsF9G0aMJDaFEo3EgM0DAAF9vFhIiVEmg/hYnBP0EAA== -->\n\n<!-- internal state end -->\n<!-- finishing_touch_checkbox_start -->\n\n<details>\n<summary>✨ Finishing Touches</summary>\n\n- [ ] <!-- {\"checkboxId\": \"7962f53c-55bc-4827-bfbf-6a18da830691\"} --> 📝 Generate Docstrings\n<details>\n<summary>🧪 Generate unit tests</summary>\n\n- [ ] <!-- {\"checkboxId\": \"f47ac10b-58cc-4372-a567-0e02b2c3d479\", \"radioGroupId\": \"utg-output-choice-group-unknown_comment_id\"} -->   Create PR with unit tests\n- [ ] <!-- {\"checkboxId\": \"07f1e7d6-8a8e-4e23-9900-8731c2c87f58\", \"radioGroupId\": \"utg-output-choice-group-unknown_comment_id\"} -->   Post copyable unit tests in a comment\n- [ ] <!-- {\"checkboxId\": \"6ba7b810-9dad-11d1-80b4-00c04fd430c8\", \"radioGroupId\": \"utg-output-choice-group-unknown_comment_id\"} -->   Commit unit tests in branch `fix-total-row-count`\n\n</details>\n\n</details>\n\n<!-- finishing_touch_checkbox_end -->\n<!-- tips_start -->\n\n---\n\nThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.\n\n<details>\n<summary>❤️ Share</summary>\n\n- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)\n- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)\n- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)\n- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)\n\n</details>\n\n<details>\n<summary>🪧 Tips</summary>\n\n### Chat\n\nThere are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=SeedCompany/cord-field&utm_content=1726):\n\n- Review comments: Directly reply to a review comment made by CodeRabbit. Example:\n  - `I pushed a fix in commit <commit_id>, please review it.`\n  - `Open a follow-up GitHub issue for this discussion.`\n- Files and specific lines of code (under the \"Files changed\" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query.\n- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:\n  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`\n  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`\n\n### Support\n\nNeed help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.\n\n### CodeRabbit Commands (Invoked using PR/Issue comments)\n\nType `@coderabbitai help` to get the list of available commands.\n\n### Other keywords and placeholders\n\n- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.\n- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.\n- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.\n\n### CodeRabbit Configuration File (`.coderabbit.yaml`)\n\n- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.\n- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.\n- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`\n\n### Status, Documentation and Community\n\n- Visit our [Status Page](https://status.coderabbit.ai) to check the current availability of CodeRabbit.\n- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.\n- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.\n- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.\n\n</details>\n\n<!-- tips_end -->"},"request":{"retryCount":1}},"response":{"url":"https://api.github.com/repos/SeedCompany/cord-field/issues/comments/3208105048","status":404,"headers":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","content-encoding":"gzip","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Thu, 21 Aug 2025 14:00:54 GMT","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"github.com","strict-transport-security":"max-age=31536000; includeSubdomains; preload","transfer-encoding":"chunked","vary":"Accept-Encoding, Accept, X-Requested-With","x-accepted-github-permissions":"issues=write; pull_requests=write","x-content-type-options":"nosniff","x-frame-options":"deny","x-github-api-version-selected":"2022-11-28","x-github-media-type":"github.v3; format=json","x-github-request-id":"6065:22A428:8DD73:1FD231:68A72696","x-ratelimit-limit":"5000","x-ratelimit-remaining":"4971","x-ratelimit-reset":"1755788137","x-ratelimit-resource":"core","x-ratelimit-used":"29","x-xss-protection":"0"},"data":{"message":"Not Found","documentation_url":"https://docs.github.com/rest/issues/comments#update-an-issue-comment","status":"404"}}}

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 in hasFilter (otherwise toolbar count stays unfiltered when only quick filter is used)

hasFilter only checks filterModel.items. If a user applies the Quick Filter (toolbar search), items can be empty while quickFilterValues is populated. In that case, the updated rowCount logic won’t switch to rows.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 align paginationMode with rowCount condition to avoid any future warnings if pagination UI is re-enabled

Right now paginationMode is set based on total != null. Since rowCount switches to rows.length only when hasFilter && isCacheComplete, you could mirror that in paginationMode to keep modes consistent (especially if footer pagination is ever shown again). Not strictly necessary today with hideFooterPagination, 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.

📥 Commits

Reviewing files that changed from the base of the PR and between bf2fbb7 and a8bdf9e.

📒 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 — LGTM

Using rows.length for rowCount when 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants