-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[data grid] GridToolbarQuickFilter loses focus when setting state variable #16061
Comments
I Just made the codesanbox public, was private by accident =) |
The reason is that you need to define the if you need the rows you can get it from the apiRef ... for components that get rendered inside the grid context and need to access it you can use const CustomToolbar = () => {
const apiRef = useGridApiContext();
const rowsCount = apiRef.current?.state?.rows.totalRowCount;
console.log('rowsCount', rowsCount);
return (
<GridToolbarContainer>{rowsCount ? <GridToolbarQuickFilter /> : null}</GridToolbarContainer>
);
}; |
This solved my issue, thanks! |
I guess im allowed to close the issue |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note @entaildevops How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
The problem in depth
I am keeping track of selected row. It works, but when a row is selected and GridToolbarQuickFilter is used, it loses focus when the currently selected row is filtered out. This leads to bad UX. How could I prevent this from happening?
Codesandbox here.
First select a row and then type something in the quick filter box to reproduce the issue.
Your environment
`npx @mui/envinfo`
Binaries:
Node: 18.16.0 - C:\Program Files\nodejs\node.EXE
npm: 9.5.1 - C:\Program Files\nodejs\npm.CMD
pnpm: Not Found
Browsers:
Chrome: Not Found
Edge: Chromium (131.0.2903.99)
Search keywords: DataGrid GridToolbarQuickFilter
Order ID: 98745
The text was updated successfully, but these errors were encountered: