From 4ac1bbc6574e23d3688ccce9ce45145737b448a9 Mon Sep 17 00:00:00 2001 From: Abhijnya002 <53806883+Abhijnya002@users.noreply.github.com> Date: Tue, 6 Jan 2026 19:14:29 -0500 Subject: [PATCH] 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 --- public/app/plugins/panel/piechart/PieChart.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/panel/piechart/PieChart.tsx b/public/app/plugins/panel/piechart/PieChart.tsx index fa10698d487..8cb6620b570 100644 --- a/public/app/plugins/panel/piechart/PieChart.tsx +++ b/public/app/plugins/panel/piechart/PieChart.tsx @@ -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) => {