Description
Summary
Hi all,
Here is the scenario that we found out while testing with both the latest rc and the beta that works correctly with React 18.
We have an SVG element that does not trigger its first click if it is focusable (or positioned inside a focusable element) that changes some state on focus.
Steps to reproduce:
Open the Stackblitz example and open its console
Click 1 time on the triangle svg element
Expected:
'svg click' message is logged
Current:
no message is logged
(On the second and all next clicks the message is shown as expected - only the first click is not triggered)
Here are the stackblitz examples where the issue can be observed:
rc: https://stackblitz.com/edit/react-vsxt51-w3ktmp?file=app%2Fapp.tsx - not working
beta: https://stackblitz.com/edit/react-vsxt51-ssqptj?file=app%2Fapp.tsx - not working
And here is how it is working in React 18:
React 18: https://stackblitz.com/edit/react-vsxt51-xsg1yu?file=app%2Fapp.tsx - working
Code:
const App = () => {
const [focused, setFocused] = React.useState(false);
const handleFocus = () => {
setFocused(true);
};
return (
<svg
onFocus={handleFocus}
tabIndex={1}
onClick={() => {
console.log('svg click');
}}
viewBox="0 0 512 512"
dangerouslySetInnerHTML={{
__html: '<path d="M256 352 128 160h256z" />',
}}
></svg>
);
};