Skip to content
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

[DataGridPro] Make default filter items have stable references in header filters #10338

Merged
merged 2 commits into from
Sep 17, 2023

Conversation

MBilalShafi
Copy link
Member

@MBilalShafi MBilalShafi commented Sep 14, 2023

Fixes #10325

The bug surfaced after #9712, the reason is the same as in #8119, i.e. till a valid filter item is defined for a column, a new default filter item is being generated on every render which is causing the useEffect in the GridFilterItemValue to be called unnecessarily hence removing the first typed character from the header filter.

Test: I didn't manage to reproduce the issue, probably it's not re-rendering that often in test env 🤔

@MBilalShafi MBilalShafi added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Filtering Related to the data grid Filtering feature labels Sep 14, 2023
@mui-bot
Copy link

mui-bot commented Sep 14, 2023

Netlify deploy preview

Netlify deploy preview: https://deploy-preview-10338--material-ui-x.netlify.app/

Updated pages

No updates.

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms -203 38.1 -53.1 -45.5 84.219
Sort 100k rows ms 650.9 1,492.5 1,416 1,223.88 297.972
Select 100k rows ms 738.9 952.9 844.1 836.78 70.152
Deselect 100k rows ms 117.7 286.6 183.7 186.78 62.934

Generated by 🚫 dangerJS against aac5faf

@MBilalShafi MBilalShafi marked this pull request as ready for review September 14, 2023 15:33
@@ -53,6 +55,7 @@ export const useGridColumnHeaders = (props: UseGridColumnHeadersProps) => {
hasOtherElementInTabSequence || columnHeaderFilterTabIndexState !== null,
});
const headerFiltersRef = React.useRef<HTMLDivElement>(null);
const filterItemsRef = React.useRef<Map<GridStateColDef['field'], GridFilterItem>>(new Map());
Copy link
Contributor

@romgrk romgrk Sep 15, 2023

Choose a reason for hiding this comment

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

Maybe just a Objcet.create(null) object here?

Copy link
Member Author

@MBilalShafi MBilalShafi Sep 16, 2023

Choose a reason for hiding this comment

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

Sure, done in aac5faf

@MBilalShafi MBilalShafi merged commit 7010922 into mui:master Sep 17, 2023
5 checks passed
@MBilalShafi MBilalShafi deleted the fix-item-reference-update branch September 17, 2023 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Filtering Related to the data grid Filtering feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] unstable_headerFilters not showing correct value with controlled filterModel
3 participants