You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Checkbox: replace useLayoutEffect with ref callback for indeterminate prop #7764
The Checkbox component currently uses a useLayoutEffect to imperatively set the DOM .indeterminate property on the underlying <input> element. While this works, it can be replaced with a ref callback, which runs synchronously during commit (same timing guarantees as useLayoutEffect) without registering a separate effect.
Replace with a ref callback that sets .indeterminate inline:
constsetIndeterminate=React.useCallback((node: HTMLInputElement|null)=>{if(node){node.indeterminate=indeterminate||false}},[indeterminate,checked],)// merge with the forwarded refconstmergedRef=useMergedRef(checkboxRef,setIndeterminate)
Additional cleanup
The useEffect that sets aria-checked can also be replaced with an inline JSX attribute:
Hi, is this still open for someone to pick up? In packages/react/src/Checkbox/Checkbox.tsx the indeterminate state is set inside a useLayoutEffect, and I'd move it into a ref callback merged through useMergedRefs and drop the separate aria-checked effect. I noticed #8548 is graduating the merged forwarded refs flag in the same file, so I'd build on top of that once it lands. Could you assign it to me?
Activity
Checkbox: replace useLayoutEffect with ref callback for indeterminate
akshat-lakhera commentedon Oct 20, 2026
Hi, is this still open for someone to pick up? In
packages/react/src/Checkbox/Checkbox.tsxthe indeterminate state is set inside auseLayoutEffect, and I'd move it into a ref callback merged throughuseMergedRefsand drop the separate aria-checked effect. I noticed #8548 is graduating the merged forwarded refs flag in the same file, so I'd build on top of that once it lands. Could you assign it to me?