Add test and make sure the help center is not reparented. #107846
Closed
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.
Proposed Changes/Why are these changes being made?
We're getting the follow error in our logs:
I unfortunately can't reproduce in production but looking at the HelpCenter code, it appears like we could have a bug. As such, I've added a test that exposes the bug and added a fix.
Theory
The Help Center portal cleanup always called
document.body.removeChild(portalParentRef.current), assuming the portal div was a direct child of document.body. If any code reparented the portal elsewhere in the DOM, unmounting would throwThe node to be removed is not a child of this nodebecausedocument.bodywas no longer its parent.I need to be clear, I cannot reproduce and this is a theory :). I haven't been able to detach the help center from the
document.body.Considerations
I think the issue was introduced in this PR: 9e5e814
I'm not certain the change here is in the right direction. I'm hoping @wellyshen can provide guidance.
Testing Instructions
Pre-merge Checklist