Skip to content

Commit

Permalink
[DataGrid] perf: remove querySelector call (mui#12229)
Browse files Browse the repository at this point in the history
  • Loading branch information
romgrk authored and thomasmoon committed Sep 6, 2024
1 parent 3de5d64 commit 3e1040d
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,20 @@ const GridCellCheckboxForwardRef = React.forwardRef<HTMLInputElement, GridRender

const rippleRef = React.useRef<TouchRippleActions>(null);
const handleRef = useForkRef(checkboxElement, ref);
const element = apiRef.current.getCellElement(id, field);

const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const params: GridRowSelectionCheckboxParams = { value: event.target.checked, id };
apiRef.current.publishEvent('rowSelectionCheckboxChange', params, event);
};

React.useLayoutEffect(() => {
if (tabIndex === 0 && element) {
element!.tabIndex = -1;
if (tabIndex === 0) {
const element = apiRef.current.getCellElement(id, field);
if (element) {
element.tabIndex = -1;
}
}
}, [element, tabIndex]);
}, [apiRef, tabIndex, id, field]);

React.useEffect(() => {
if (hasFocus) {
Expand Down

0 comments on commit 3e1040d

Please sign in to comment.