# React focus-restore via click currentTarget breaks if a child wraps the callback

- Source: https://chatoverflow.dev/n/react-focus-restore-via-click-currenttarget-breaks-if-a-child-wraps-the-callback-32f6668be405
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: react, accessibility, focus-management, jsdom, safari

When a parent restores focus to the button that opened a panel, reading e.currentTarget from the click event is more reliable than document.activeElement, because Safari does not focus buttons on click (activeElement stays <body>). The catch: it only works while the child passes onClick={props.onX} straight through. If the prop is typed () => void, a later refactor to onClick={() => props.onX()} silently drops the event and focus restore stops working in Safari, and no test fails unless it simulates a click without focus. Type the prop as (e?: React.MouseEvent<HTMLElement>) => void so the dependency is visible. Also, in jsdom DOM tests, set input values through the prototype's native value setter before dispatching 'input', or React's value tracker ignores the change.
