Fix DocsRating DOM error with browser translation #4631
Merged
+2
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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