-
Notifications
You must be signed in to change notification settings - Fork 47.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[React 19] [bug] SVG with dangerouslySetInnerHTML content does not trigger first click #30994
Comments
Hi, I noticed this issue and I'd like to contribute to help resolve it. I have experience working with React, SVG elements, and event handling, and I believe I can assist in identifying the root cause or proposing a solution. This will be my first time contributing to open source, so I’d appreciate any guidance on the next steps or specific areas of the codebase I should focus on. I’ll start by reproducing the issue locally and analysing the behaviour across different React versions. Looking forward to contributing |
Hi, import * as React from 'react'; const App = () => { return ( export default App; |
@nareshmurty - Indeed, this is part of the bug scenario - the issue is observed when any change of the state is attempted in the onFocus event - it should be possible to change the state in this event and currently it is not. |
@zdravkov - I got a solution related to the above scenario but I don't know whether it is the best way or not.
import * as React from 'react'; const App = () => { return ( export default App; |
@nareshmurty thank you for your efforts! The suggested approach rather seems like a workaround than a solution to me. A solution here would be fixing the bug in the new React 19 codebase. |
Hi @zdravkov Inside the Element.js component:
Inside the tests/ReactDOMSVG-test.js fileHere's the test I wrote to test this out:
Output:And here are the results after running the test:
Let me know if this looks good enough for me to make a PR. Please note- I only ran the ReactDOMSVG-test to ensure nothing breaks, but if you think that there are tests elsewhere that could potentially break, let me know and I'll run a full test too. Looking forward to your feedback! |
Thank you for your help with the issue and the contribution, I am not quite familiar with the code rules of this repo, so I can't provide good opinion on your pr. I hope somebody from the core team will check it soon! :) |
Thank you for reporting. This is a pretty obscure bug. It requires It started breaking in https://www.npmjs.com/package/react/v/18.3.0-next-85de6fde5-20230328 First bad: https://www.npmjs.com/package/react/v/18.3.0-next-85de6fde5-20230328 Diff: 41b4714...85de6fd Likely candidate is #26501. It's a big diff but maybe somebody is able to spot an issue. |
Hey all, The pr from @koushikjoshi seems to be fixing it - #31038 Greetings, |
Hi @zdravkov Thanks, |
It might be implied by @eps1lon's comment, but seems that this bug not limited to A sandbox with a button + span: |
On a second thought... I think this might not be a bug with react. Prior to #26501 it was working, since some changes (in this case the Initial example modified so that the innerHTML also diffs: Replicated what ReactDOM is doing under the hood with raw HTML/JS, and it behaves the same - setting Referring to the original example with the |
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:
The text was updated successfully, but these errors were encountered: