Skip to content

Commit

Permalink
fix(dataGrid): focus loss on radio select (#6073)
Browse files Browse the repository at this point in the history
* fix(dataGrid): focus loss on radio select

* fix: added optional ? on document

* chore: added conditional ? on document
  • Loading branch information
devadula-nandan authored Sep 25, 2024
1 parent 6c7823e commit 127824b
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const SelectRow = (datagridState) => {
return () => window.removeEventListener('resize', updateSize);
}, []);

const onSelectHandler = (event) => {
const onSelectHandler = async (event) => {
event.stopPropagation(); // avoid triggering onRowClick
if (radio) {
toggleAllRowsSelected(false);
Expand All @@ -119,6 +119,10 @@ const SelectRow = (datagridState) => {
getRowId,
selectAll: null,
});
// focus the radio / checkbox if lost
const activeElement = document?.activeElement?.id ?? '';
await undefined;
document?.getElementById(activeElement)?.focus();
};

const selectDisabled = isFetching || row.getRowProps().disabled;
Expand Down

0 comments on commit 127824b

Please sign in to comment.