-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] AutoComplete looses focus on first selection after user starts typing #13702
Comments
Thanks for reporting the issue @BeckmannArmin, I have also managed to reproduce the issue using your example, and my own example forked from the custom header filter demo. I will add this to the board for prioritisation. |
Thanks. Sounds "good" that this is an issue for everyone and not on our end. Will you update here once the issue is resolved? |
@BeckmannArmin yes, we will update this issue when a fix is available. |
This issue might be related to #13734 |
@KenanYusuf Are there any updates? Our users are wating desperately for a fix. We re running our app in a productive environment where every clicks costs time (money). |
Working on a fix for this @BeckmannArmin - should be available soon. |
Hey @BeckmannArmin @MBilalShafi took a look at your example and managed to fix the issue you were seeing by passing const renderInput = useCallback((params) => {
return (
<TextField
{...params}
variant="standard" />
++ inputRef={props.inputRef}
/>
);
}, []); Hopefully that solves it, but let me know if you're still experiencing the problem. |
inputRef does not exist in the props validation. Neither does it in the params for the renderInput function. |
Could you provide or adjust the example from above accordingly? @KenanYusuf |
Hey @BeckmannArmin ... The inputRef is coming from the mui-x/packages/x-data-grid-pro/src/components/headerFiltering/GridHeaderFilterCell.tsx Lines 329 to 334 in 883d1f8
|
The issue has been inactive for 7 days and has been automatically closed. |
The problem in depth
Hey,
We are using custom filter operators in our application to render a Autocomplete inside the header filter cell to let the user search and select multiple values to filter the data inside the DataGrid.
However when using a Autocomplete as a header filter only every second input is registered. The component itself seems to loose its focus when you first focus it and then start typing on your keyboard.
I tried to debug it and stumbled across the layoutEffect function inside GridHeaderFilterCell.js (line 92-102)
React.useLayoutEffect(() => { if (hasFocus && !isMenuOpen) { let focusableElement = cellRef.current.querySelector('[tabindex="0"]'); if (isEditing && InputComponent) { focusableElement = inputRef.current; } const elementToFocus = focusableElement || cellRef.current; elementToFocus?.focus(); apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0; } }, [InputComponent, apiRef, hasFocus, isEditing, isMenuOpen]);
Maybe this is the right palce to look for.
Here is an example
Steps to reproduce:
We are expecting that the user can start typing as soon as he selects the field.
Your environment
`npx @mui/envinfo`
Search keywords: autocomplete
Order ID: 83002
The text was updated successfully, but these errors were encountered: