-
-
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
[DataGridPro] Fix custom header filter keyboard control when triggered via space key #14067
Changes from 3 commits
3b3e4ae
d791ac9
843ec91
28a2fe1
7271531
15dd85e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,7 +183,7 @@ const GridHeaderFilterCell = React.forwardRef<HTMLDivElement, GridHeaderFilterCe | |
|
||
const onKeyDown = React.useCallback( | ||
(event: React.KeyboardEvent) => { | ||
if (isMenuOpen || isNavigationKey(event.key) || isFilterReadOnly) { | ||
if (isMenuOpen || (event.key !== ' ' && isNavigationKey(event.key)) || isFilterReadOnly) { | ||
return; | ||
} | ||
switch (event.key) { | ||
|
@@ -259,6 +259,7 @@ const GridHeaderFilterCell = React.forwardRef<HTMLDivElement, GridHeaderFilterCe | |
if (inputRef.current?.contains?.(event.target as HTMLElement)) { | ||
inputRef.current.focus(); | ||
} | ||
apiRef.current.startHeaderFilterEditMode(colDef.field); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MBilalShafi unsure if there will be any side effects to this change, but it made sense to me in theory that when a custom filter is clicked it should be in edit mode There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it will change the current behavior of the header filters. Each header filter cell has two states:
How to shift from Focus state to Edit state?
How to shift from Edit state to Focus state? If we make it go to the edit mode on click:
Coming to the problem of not activating the Autocomplete field on Start typing, I think that's because the The proper fix would be done with #9243 I guess that would handle selecting multiple values internally. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This makes sense, and it fixes the user's example. I will go back to them with this fix and revert the change here.
KenanYusuf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
apiRef.current.setColumnHeaderFilterFocus(colDef.field, event); | ||
} | ||
}, | ||
|
@@ -319,7 +320,7 @@ const GridHeaderFilterCell = React.forwardRef<HTMLDivElement, GridHeaderFilterCe | |
}} | ||
role="columnheader" | ||
aria-colindex={colIndex + 1} | ||
aria-label={headerFilterComponent == null ? (colDef.headerName ?? colDef.field) : undefined} | ||
aria-label={headerFilterComponent == null ? colDef.headerName ?? colDef.field : undefined} | ||
{...other} | ||
{...mouseEventsHandlers} | ||
> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space is technically a navigation key, but this is an exception as it can also be used to trigger inputs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, I chose not to do this for consistency as it's also not with the normal Grid cells. It was the case for the normal Grid cells too, but we removed it while fixing a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok that's interesting. Here's what I am confused about...
In both of the images below, the cells have been navigated to via keyboard, but the controls within the cells look like they are in different states. The text field looks blurred, and the select looks focused.
Should the select field also be in a blurred state to avoid confusion here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the interaction with the
singleSelect
column type is not great via keyboard, especially with the customizations. (Select / Autocomplete etc)We could also rethink how the keyboard navigation works with header filters. We have already discussed this in detail during the feature implementation (point no 5). I have a feeling we have room for improvement here. 🤔
Probably we could focus on the input field by default when the cell is focused, but then how the keyboard navigation will work smoothly is something I'm unsure about.
What do you think?