Skip to content

fix: prevent removing outgoing detail when its slot is reassigned#11485

Merged
vursen merged 3 commits intomainfrom
fix/mdl-outgoing-detail-slot-check
Apr 14, 2026
Merged

fix: prevent removing outgoing detail when its slot is reassigned#11485
vursen merged 3 commits intomainfrom
fix/mdl-outgoing-detail-slot-check

Conversation

@vursen
Copy link
Copy Markdown
Contributor

@vursen vursen commented Apr 14, 2026

Summary

  • Add a slot check in __replaceTransition's finally block so the outgoing detail element is only removed when its slot is still detail-outgoing
  • This allows _startTransition callers to reassign the outgoing element to a different slot (e.g. detail-hidden) to preserve it in the DOM
  • Add a test verifying the element is not removed when its slot is reassigned during a manual replace transition

This fixes a JS error that occurred in the React component because the web component removed the outgoing detail element, which should have been removed by React instead – a regression that was introduced by #11437 .

Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
    at removeChild (react-dom-client.development.js:22205:22)
    at runWithFiberInDEV (react-dom-client.development.js:871:30)
    at commitDeletionEffectsOnFiber (react-dom-client.development.js:14321:17)
    at recursivelyTraverseMutationEffects (react-dom-client.development.js:14555:11)
    at commitMutationEffectsOnFiber (react-dom-client.development.js:14591:11)
    at recursivelyTraverseMutationEffects (react-dom-client.development.js:14576:11)
    at commitMutationEffectsOnFiber (react-dom-client.development.js:14821:11)
    at recursivelyTraverseMutationEffects (react-dom-client.development.js:14576:11)
    at commitMutationEffectsOnFiber (react-dom-client.development.js:14591:11)
    at recursivelyTraverseMutationEffects (react-dom-client.development.js:14576:11)

Check that the outgoing detail's slot is still 'detail-outgoing' before
removing it in the replace transition's finally block. This allows
_startTransition callers to reassign the outgoing element to a different
slot (e.g. 'detail-hidden') to preserve it in the DOM.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vursen vursen requested a review from sissbruecker April 14, 2026 10:30
]);
} finally {
if (oldDetail) {
if (oldDetail && oldDetail.slot === 'detail-outgoing') {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess a comment here or in the test couldn't hurt on why this is necessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done.

vursen and others added 2 commits April 14, 2026 19:38
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

@vursen vursen merged commit b6813f8 into main Apr 14, 2026
10 checks passed
@vursen vursen deleted the fix/mdl-outgoing-detail-slot-check branch April 14, 2026 16:39
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.

2 participants