Fix modals not being dismissed properly #26840
Closed
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.
Summary
Improve the algorithm for determining the view controller for presentation of
RCTModalHostViewController
.The problem was that
RCTModalHostViewManager
always used the first responder view controller ([modalHostView reactViewController]
), whereas it is possible that such controller also had presented another view controller on top of itself (and that one could present yet another VC, and so on). So we walk through the presentedViewController chain to find the top-most presented VC.These changes fix a bug where if you present 2 modals on top of each other, you would not be able to click on anything on the screen after they go away because there is a
RCTModalHostView
hanging around in the view hierarchy on top of everything else.My previous pull request related to this issue: #22666 (closed).
Changelog
[iOS] [Fixed] - Fixed a bug with modals blocking user input after they are hidden
Test Plan
I have a test project that demonstrates the bug and allows one to verify this fix (bugs no. 2 and 3 in the bug list). The project is made with React 0.61.2.