Repository navigation
fix: differentiate host layers by id and self register - #3862
Merged
Merged
Conversation
Contributor
SDK Size
|
oliverlaz
approved these changes
Oct 16, 2026
1 of 6 tasks
Contributor
|
π This PR is included in version 9.10.1 π The release is available on:
Your semantic-release bot π¦π |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
π― Goal
Fixes #3860.
Linear ticket: https://linear.app/stream/issue/RN-444/issues-with-chat-overlays-in-modals
A chat rendered inside a native modal (for example a
react-navigationfullScreenModal) needs its ownOverlayProvider, because on iOS the root one is rendered in a different view controller, behind the modal. With a secondOverlayProvidermounted, the message overlay of the root chat breaks once the modal is closed.Every
MessageOverlayHostLayershares two pieces of state. One is the shared value controller inmessage-overlay-store.ts. The other is the set of portal host names (message-overlay,top-item,bottom-itemand the closing slots), whichreact-native-teleportkeeps in a single native registry per process. In both cases the last registration wins, and unregistering removes the entry instead of restoring the previous one. After the modal's provider unmounted, the root provider was left without a controller and without registered hosts.This PR makes sure several
OverlayProviders mounted at the same time work, without changing the existing public API.π Implementation details
registerOverlaySharedValueControllerkeeps its signature, and unregistering hands control back to the previously registered controller. It's pretty much the same "trick" used for thePortalWhileClosingViewstack.OverlayProvidercreates an id and registers itsMessageOverlayHostLayeron a host layer stack. The most recently mounted layer is the top one and owns the overlay.<name>:<layerId>, closing slots included) and takes the shared names back once it becomes the top one again. The hosts are renamed instead of unmounted, because remounting them lets Fabric reuse a recycledPortalHostView, which might keep stale sizes. Of course we could work around this and still let stuff remount but it's also arguably breaking since we have configurable parts of the DOM tree in there (and those parts would start remounting rather than just rerendering).MessageActionsrenders its own hosts with the shared names, so only the top layer renders it.PortalWhileClosingViewreads the id of its provider from a new internalOverlayHostLayerContextand only measures and teleports while that provider is the top one.With a single
OverlayProviderthe stack has one entry and every code path should behave exactly as before.Note: This entire process is meant to solve specifically usecases like modals, which fire up their own
ModalViewControllerinstance and essentially break. Due to the limitations of refcounting providers in order to determine their ID, having something like 2OverlayProviders side by side would not really work (whichever one gets registered later wins). This fixable, but of course breaking as the api itself would have to be tied to a dedicatedOverlayProvider(and could no longer be used from the direct exports). It is something I'll consider for V10, if there is time but otherwise we'll stick to this for the time being.π¨ UI Changes
iOS
Android
π§ͺ Testing
/
βοΈ Checklist
developbranch