feat(mui): Add configurable filter debouncing to useDataGrid hook#7396
Open
Alex-Murmu wants to merge 4 commits intorefinedev:mainfrom
Open
feat(mui): Add configurable filter debouncing to useDataGrid hook#7396Alex-Murmu wants to merge 4 commits intorefinedev:mainfrom
Alex-Murmu wants to merge 4 commits intorefinedev:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 0c927f5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
Adds configurable, mode-based debouncing for server-side filter updates in the @refinedev/mui useDataGrid hook to reduce request flooding and improve typing UX (issue #7369).
Changes:
- Introduces
filterDebounceMs,filterDebounceMode(smart/all/off), debounce lifecycle callbacks, andisPendingFiltersstate touseDataGrid. - Updates server-side
onFilterModelChangehandling to debounce filter application based on mode. - Also bumps monorepo tooling deps (
lerna,nx,vitest) and relaxes typing in Appwrite sorting utility.
Reviewed changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| packages/mui/src/hooks/useDataGrid/index.ts | Adds new hook options/state and implements debounced server-side filter application logic. |
| packages/appwrite/src/utils/getAppwriteSorting.ts | Changes sorter iteration typing (introduces any) in Appwrite query sorting helper. |
| package.json | Upgrades dev tooling dependencies (lerna/nx/vitest). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ad9cf0f to
17e6c30
Compare
- Add filterDebounceMs option (default: 500ms)
- Add filterDebounceMode option ('smart', 'all', 'off')
- Add onFilterDebounceStart and onFilterDebounceEnd callbacks
- Add isPendingFilters state tracking
- Smart mode debounces only text filters
- Fixes refinedev#7369
fix: feat(mui): Add configurable filter debouncing to useDataGrid hook
- Remove unused useDebounce hook
- Fix smart mode to only debounce when text filters present
- Add eq/ne/ncontains to text operators list
- Fix isPendingFilters state consistency
- Add comprehensive tests for debouncing behavior
- Add changeset for version bump
17e6c30 to
4019794
Compare
- Revert vitest from ^4.1.4 to ^2.1.8 (unrelated to filter debouncing feature) - Revert lerna from ^9.0.7 to ^6.2.0 (unrelated to this PR) - Revert nx from ^22.6.5 to ^18.0.0 (unrelated to this PR) - Fix Appwrite sorting typing from 'any' to proper CrudSorting type
…n text edits In smart mode, only apply categorical filters when they actually change, not on every keystroke. This prevents defeating the debouncing mechanism when both text and categorical filters are active. - Add previousCategoricalFiltersRef to track categorical filter state - Only apply categorical filters if they changed (deep equality check) - Fixes: categorical filters re-triggering API calls on every keystroke when text filters are being debounced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
Bugs / Features
What is the current behavior?
The
useDataGridhook sends API requests on every filter change, including every keystroke in text filters. This causes:Related to issue #7369
What is the new behavior?
Added configurable, smart filter debouncing:
filterDebounceMsoption (default: 500ms) - Controls debounce delayfilterDebounceModeoption - Three modes:'smart'(default): Only debounce text filters (contains, startswith), apply categorical filters (eq, in) immediately'all': Debounce all filter changes'off': No debouncingonFilterDebounceStartandonFilterDebounceEndfor loading statesisPendingFiltersstate: Track when filters are being debouncedExample Usage