Skip to content

perf(data-grid): optimize data-grid-filter-menu - #1039

Merged
sadmann7 merged 5 commits into
mainfrom
clean-filter
Nov 25, 2025
Merged

sadmann7 merged 5 commits into
mainfrom
clean-filter

Conversation

@sadmann7

Copy link
Copy Markdown
Owner
  • Remove unnecessary state management and useEffect anti-patterns
  • Use uncontrolled inputs with key-based reset for text/number filters
  • Prevent re-renders on every keystroke during filtering
  • Simplify conditional logic for filter value inputs
  • Extract constants and improve variable naming
  • Follow React best practices from workspace rules

- Remove unnecessary state management and useEffect anti-patterns
- Use uncontrolled inputs with key-based reset for text/number filters
- Prevent re-renders on every keystroke during filtering
- Simplify conditional logic for filter value inputs
- Extract constants and improve variable naming
- Follow React best practices from workspace rules
Copilot AI review requested due to automatic review settings November 25, 2025 12:45
@vercel

vercel Bot commented Nov 25, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
shadcn-table Ready Ready Preview Comment Nov 25, 2025 2:06pm
tablecn Ready Ready Preview Comment Nov 25, 2025 2:06pm

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes the data-grid-filter-menu component by refactoring state management, simplifying conditional logic, and extracting constants. However, it introduces a critical bug in the text and number input handling.

Key Changes:

  • Extracts OPERATORS_WITHOUT_VALUE constant for improved maintainability
  • Simplifies conditional rendering logic for filter inputs (fixes "between" operator bug)
  • Attempts to optimize text/number inputs by switching to uncontrolled components with key-based reset
  • Improves variable naming and removes duplicate declarations

Critical Issue:
The switch to uncontrolled inputs with key={inputId}-${value} causes inputs to remount and lose focus after the 300ms debounce period. This significantly degrades user experience as users will lose their cursor position while typing.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/data-grid/data-grid-filter-menu.tsx Outdated
Comment thread src/components/data-grid/data-grid-filter-menu.tsx Outdated
- Rename value2 to endValue for better semantic clarity
- Handle 'between' operator with side-by-side inputs (no layout shift)
- Use single calendar with range mode for date ranges (like data-table)
- Fix focus loss issue by using filter.id as key instead of values
- Maintain local state with debounced updates for smooth typing
- Consistent placeholders: 'Start' and 'End' for range inputs
- Remove component-level key prop that caused remounting
@sadmann7
sadmann7 merged commit 444e1ab into main Nov 25, 2025
7 checks passed
@sadmann7
sadmann7 deleted the clean-filter branch November 25, 2025 14:07
noodleman1991 pushed a commit to noodleman1991/tablecn that referenced this pull request Mar 12, 2026
* refactor: optimize data-grid-filter-menu performance

- Remove unnecessary state management and useEffect anti-patterns
- Use uncontrolled inputs with key-based reset for text/number filters
- Prevent re-renders on every keystroke during filtering
- Simplify conditional logic for filter value inputs
- Extract constants and improve variable naming
- Follow React best practices from workspace rules

* refactor: improve data-grid filter menu UX and naming

- Rename value2 to endValue for better semantic clarity
- Handle 'between' operator with side-by-side inputs (no layout shift)
- Use single calendar with range mode for date ranges (like data-table)
- Fix focus loss issue by using filter.id as key instead of values
- Maintain local state with debounced updates for smooth typing
- Consistent placeholders: 'Start' and 'End' for range inputs
- Remove component-level key prop that caused remounting

* feat: better date menu

* feat: better filter menu
anhdd-kuro pushed a commit to anhdd-kuro/tablecn that referenced this pull request Apr 8, 2026
* refactor: optimize data-grid-filter-menu performance

- Remove unnecessary state management and useEffect anti-patterns
- Use uncontrolled inputs with key-based reset for text/number filters
- Prevent re-renders on every keystroke during filtering
- Simplify conditional logic for filter value inputs
- Extract constants and improve variable naming
- Follow React best practices from workspace rules

* refactor: improve data-grid filter menu UX and naming

- Rename value2 to endValue for better semantic clarity
- Handle 'between' operator with side-by-side inputs (no layout shift)
- Use single calendar with range mode for date ranges (like data-table)
- Fix focus loss issue by using filter.id as key instead of values
- Maintain local state with debounced updates for smooth typing
- Consistent placeholders: 'Start' and 'End' for range inputs
- Remove component-level key prop that caused remounting

* feat: better date menu

* feat: better filter menu

This branch was successfully deployed

2 active deployments
Preview – tablecn — 8896b0ed Deployed Nov 25, 2025 by vercel[bot]
Preview – shadcn-table — 8896b0ed Deployed Nov 25, 2025 by vercel[bot]
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