From 17ebd1b2f7217a1e503fd9505d8948fc911c8f32 Mon Sep 17 00:00:00 2001 From: ShaneK Date: Tue, 8 Apr 2025 09:33:17 -0700 Subject: [PATCH] fix(overlay): prevent orphaned DOM elements during dismiss by removing setState to stop race conditions --- .../react/src/components/createInlineOverlayComponent.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/react/src/components/createInlineOverlayComponent.tsx b/packages/react/src/components/createInlineOverlayComponent.tsx index 65f1711cbb7..6127cc354ca 100644 --- a/packages/react/src/components/createInlineOverlayComponent.tsx +++ b/packages/react/src/components/createInlineOverlayComponent.tsx @@ -199,8 +199,10 @@ export const createInlineOverlayComponent = ( * that removes the item.) */ if (wrapper && el) { + // The delegate's removeViewFromDom call handles unmounting the React component. + // Setting state here can cause race conditions. + // Restore the wrapper to the element before the delegate removes it. el.append(wrapper); - this.setState({ isOpen: false }); } this.props.onDidDismiss && this.props.onDidDismiss(evt);