Skip to content

Fix DocsRating DOM error with browser translation#4631

Merged
Simek merged 2 commits into
react:mainfrom
jungwoo3490:fix-browser-translation-dom-error
Jun 18, 2025
Merged

Fix DocsRating DOM error with browser translation#4631
Simek merged 2 commits into
react:mainfrom
jungwoo3490:fix-browser-translation-dom-error

Conversation

@jungwoo3490

Copy link
Copy Markdown
Contributor

The DocsRating component crashes with a DOM manipulation error when users have browser translation enabled and click the thumbs up/down buttons.

2025-06-05.2.04.43.mov

When the component initially renders, the React Fragment causes the text node "Is this page useful?" and SVG elements to be directly attached to the parent div without any wrapper container. The browser's translation feature then detects this text node and directly manipulates the DOM to replace it with translated content, which modifies the DOM structure outside of React's control.

When a user clicks the thumbs up or down button, it triggers setHaveVoted(true), causing React to re-render and attempt to remove the existing Fragment content from the DOM. However, since the translation tool has already altered the DOM structure, the nodes that React expects to find are no longer in their original positions or have been replaced entirely, leading to a mismatch between React's virtual DOM and the actual DOM.

This discrepancy causes React to fail when trying to remove child nodes that are no longer children of their expected parent, ultimately resulting in the "removeChild failed - not a child" error being thrown.

So I replaced <> Fragment with <div> in DocsRating component. So now, even when translation tools modify the internal text, the div container itself remains intact.

2025-06-05.2.52.04.mov

@facebook-github-bot

Copy link
Copy Markdown

Hi @jungwoo3490!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@netlify

netlify Bot commented Jun 4, 2025

Copy link
Copy Markdown

Deploy Preview for react-native ready!

Name Link
🔨 Latest commit a61fc7f
🔍 Latest deploy log https://app.netlify.com/projects/react-native/deploys/6840916a9f56ae000880fcff
😎 Deploy Preview https://deploy-preview-4631--react-native.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@facebook-github-bot

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@Simek Simek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching the translate issue! 👍 In this case it's fine to replace fragment with div, so merging in.

@Simek Simek merged commit fec2f1f into react:main Jun 18, 2025
4 checks passed
coado pushed a commit to coado/react-native-website that referenced this pull request Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants