Skip to content

Commit b02e8f6

Browse files
wip
1 parent cc3375c commit b02e8f6

File tree

1 file changed

+8
-5
lines changed
  • polaris-react/src/components/IndexTable/components/Checkbox

1 file changed

+8
-5
lines changed

polaris-react/src/components/IndexTable/components/Checkbox/Checkbox.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import React, {
88
ReactNode,
99
} from 'react';
1010

11+
import {debounce} from '../../../../utilities/debounce';
1112
import {useI18n} from '../../../../utilities/i18n';
1213
import {classNames} from '../../../../utilities/css';
1314
import {RowContext} from '../../../../utilities/index-table';
@@ -60,16 +61,18 @@ export function CheckboxWrapper({children}: CheckboxWrapperProps) {
6061
const {position} = useContext(RowContext);
6162
const checkboxNode = useRef<HTMLTableDataCellElement>(null);
6263

63-
const handleResize = useCallback(() => {
64-
if (position !== 0) return;
64+
// eslint-disable-next-line react-hooks/exhaustive-deps
65+
const handleResize = useCallback(
66+
debounce(() => {
67+
if (position !== 0) return;
6568

66-
requestAnimationFrame(() => {
6769
if (!checkboxNode.current) return;
6870

6971
const {width} = checkboxNode.current.getBoundingClientRect();
7072
setRootProperty('--pc-checkbox-offset', `${width}px`);
71-
});
72-
}, [position]);
73+
}),
74+
[position],
75+
);
7376

7477
useEffect(() => {
7578
handleResize();

0 commit comments

Comments
 (0)