File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
polaris-react/src/components/IndexTable/components/Checkbox Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import React, {
88 ReactNode ,
99} from 'react' ;
1010
11+ import { debounce } from '../../../../utilities/debounce' ;
1112import { useI18n } from '../../../../utilities/i18n' ;
1213import { classNames } from '../../../../utilities/css' ;
1314import { 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 ( ) ;
You can’t perform that action at this time.
0 commit comments