refactor: simplify ensureNotFocusable calls

- Remove unnecessary 100ms setTimeout call
- Keep immediate call and setTimeout(0) to handle React render timing
- Add comments explaining the rationale
- Addresses review feedback on code clarity
This commit is contained in:
Abhijnya002
2026-01-06 19:14:29 -05:00
parent d46947ccb2
commit 4ac1bbc657
@@ -233,14 +233,16 @@ function PieSlice({
}
if (elementRef.current) {
// Ensure the SVG element is not focusable when parent anchor handles focus
// Use setTimeout(0) to ensure this runs after React has applied JSX attributes
const ensureNotFocusable = () => {
if (elementRef.current && elementRef.current.getAttribute('tabIndex') !== '-1') {
elementRef.current.setAttribute('tabIndex', '-1');
}
};
// Run immediately and after React's render cycle to catch any timing issues
ensureNotFocusable();
setTimeout(ensureNotFocusable, 0);
setTimeout(ensureNotFocusable, 100);
}
const handleAnchorFocus = (e: FocusEvent) => {