fix: resolve strict mode incompatibilities with portals and popups (FE-7197) #7688
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 behaviour
For Carbon components involving React Portals, resolve inconsistencies in rendering behaviour:
Portal- when unmounting, properly clean up DOM node created as the container for the portal contentPopover- always render portal content in document body or nearest Carbon modal, to avoid the need to create and cleanup a DOM node.CarbonProvider- ensure global used in updating topmost modal is cleaned up properly.Current behaviour
Since #7148 was released, several Carbon components that use React Portals show unexpected behaviour when React Strict Mode is enabled, such as modals and popups not appearing at all. This occurs because these components have rendering inconsistencies that are surfaced by the stricter Strict Mode checks introduced in React v18.
Before upgrading Carbon to support newer React versions, we should ensure all components behave correctly under Strict Mode to prepare for future React changes.
Checklist
d.tsfile added or updated if requiredQA
Additional context
Testing instructions
npm run start:strict-modeAdvancedColorPickerAlertConfirmDialogSidebarMenuFullscreenResponsiveVerticalMenuToastTooltipVerticalMenuFullscreen