Skip to content

Conversation

@StevenDufresne
Copy link
Contributor

@StevenDufresne StevenDufresne commented Dec 23, 2025

Proposed Changes/Why are these changes being made?

We're getting the follow error in our logs:

Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.

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 throw The node to be removed is not a child of this node because document.body was 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

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you tested accessibility for your changes? Ensure the feature remains usable with various user agents (e.g., browsers), interfaces (e.g., keyboard navigation), and assistive technologies (e.g., screen readers) (PCYsg-S3g-p2).
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
    • For UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)? The length of text and words vary significantly between languages.
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@matticbot
Copy link
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • help-center
  • notifications
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug try/helpcenter-fix-reparenting-error on your sandbox.

@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Dec 23, 2025
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants