Skip to content

Commit b8878b3

Browse files
committed
trim the duplicated hide/reveal explanation
1 parent b8f454b commit b8878b3

1 file changed

Lines changed: 8 additions & 18 deletions

File tree

packages/react/src/components/createInlineOverlayComponent.tsx

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,8 @@ export const createInlineOverlayComponent = <PropType, ElementType>(
5757
stableMergedRefs: React.RefCallback<HTMLElement>;
5858
portalTarget: HTMLElement | null;
5959
isUnmounted = false;
60-
/**
61-
* A relocated nested host removed in `componentWillUnmount`, together with
62-
* the comment left in its place, so `componentDidMount` can put it back
63-
* where it was when React was only hiding this subtree rather than
64-
* destroying it.
65-
*/
60+
// A nested host removed in `componentWillUnmount`, with the comment left in
61+
// its place, so `componentDidMount` can put it back where it was.
6662
removedHost: { node: HTMLElement; anchor: Comment } | null = null;
6763

6864
constructor(props: InternalProps) {
@@ -94,13 +90,10 @@ export const createInlineOverlayComponent = <PropType, ElementType>(
9490
// componentWillUnmount.
9591
this.isUnmounted = false;
9692

97-
/**
98-
* React also calls `componentWillUnmount` when it *hides* a subtree
99-
* rather than destroying it, and mounts the same instance again on the
100-
* reveal. Put back a nested host removed there, at the position it was
101-
* removed from: core reads document order to decide which overlay is on
102-
* top. See createInlineOverlayComponent.spec.tsx for the full flow.
103-
*/
93+
// React runs `componentWillUnmount` when it only hides a subtree and
94+
// mounts the same instance again on the reveal, so a host removed there
95+
// goes back at the position it came from - document order decides which
96+
// overlay is on top. The spec covers the flow.
10497
const { removedHost } = this;
10598
this.removedHost = null;
10699
if (removedHost) {
@@ -174,11 +167,8 @@ export const createInlineOverlayComponent = <PropType, ElementType>(
174167
* Nested overlays render inline inside a `<template>`. If the host
175168
* has been moved out of that template, React's unmount won't reach
176169
* it, so remove it directly. A host still in its template is left
177-
* for React to remove.
178-
*
179-
* A comment takes the host's place, the way CoreDelegate marks a
180-
* teleport, so `componentDidMount` can put the host back in the same
181-
* spot if this turns out to be a hide rather than a real unmount.
170+
* for React to remove. A comment marks the spot, the way CoreDelegate
171+
* marks a teleport, so a reveal can put the host back where it was.
182172
*/
183173
const parent = node.parentElement;
184174
if (parent && !(parent instanceof HTMLTemplateElement)) {

0 commit comments

Comments
 (0)