Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using nested, native-stack navigators, a modal screen in the inner navigator cannot push a modal screen in the outer navigator #1829

Closed
tpcstld opened this issue Jul 15, 2023 · 2 comments · Fixed by #1912
Assignees
Labels
Area: Modal Issue related with iOS modal stack presentation Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided

Comments

@tpcstld
Copy link

tpcstld commented Jul 15, 2023

Description

Screen.Recording.2023-07-14.at.11.58.46.PM.mov

I admit that this wording is a little confusing but let me try to explain what's going on. This seems to affect iOS only.

In the demo snack, I expect to be able to launch the "outer modal" -- the screen with name modal -- in the outer navigator from any other screen in this app. For example:

  • I can navigate to modal from the starting screen home.
  • I can navigate to modal from the inner navigator base screen, base.

However, I am unable to navigate to modal from inner-modal.

This is unexpected because if I were to remove the presentation: modal from inner-modal, then modal would pop-up normally. In addition, if inner-modal were in the same navigator as modal, then it would work, as evidenced by modal being able to navigate to `modal-2.

In addition, after this occurs, nothing is able to launch modal anymore, including the buttons which worked before!

Steps to reproduce

  1. Open the snack; iOS simulator
  2. Open the Inner Navigator
  3. Open the Inner Modal
  4. Try to open the Outer Modal from the Inner Modal
  5. Observe that it does not work.

Snack or a link to a repository

https://snack.expo.dev/fnbHe-IiWz

Screens version

3.18.0

React Native version

0.70.0

Platforms

iOS

JavaScript runtime

Hermes

Workflow

None

Architecture

Paper

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Repro provided A reproduction with a snack or repo is provided Platform: iOS This issue is specific to iOS labels Jul 15, 2023
@tboba
Copy link
Member

tboba commented Jul 17, 2023

Hi @tpcstld, thanks for reporting this bug! I believe this issue could be related to #1813. Have you spotted similar behavior with freezing nested modals, or you cannot just perform actions there?

@tpcstld
Copy link
Author

tpcstld commented Jul 17, 2023

When I do nest modals (on the same navigator), the nested modals do seem to be working! 🤔

@tboba tboba added the Area: Modal Issue related with iOS modal stack presentation label Jul 18, 2023
@kkafar kkafar self-assigned this Oct 4, 2023
kkafar added a commit that referenced this issue Dec 7, 2023
## Description

Closes #1829

Currently it is not possible to navigate to a modal from another modal
view that is mounted in JS under nested stack (see #1829 description for
better context).
This is the case, because modal is presented by
`RNSNavigationController` corresponding to the stack under which it is
mounted in JS ==> UIKit reports that such controller is already
presenting.

IMO the last presented modal should be the one, to present new one.


## Changes

Added code handling above case, by checking whether modals from other
stacks are present & using top-most modal for presentation in such case.

## Test code and steps to reproduce

See `Test1829` in test example apps

## Checklist

- [x] Included code example that can be used to test this change
- [x] Ensured that CI passes (merged only comments after final CI
checks)
kkafar added a commit that referenced this issue Apr 27, 2024
## Description

Basically this is another edition of the issue #1829 (handled by #1912).
The issue comes down to the fact, that our `ScreenStack` is not aware of
all modal view controllers being in presentation,
but this time it is not aware of third-party modal view controllers
(I've named them "foreign" modals in opposite to "owned" modals).

This PR is not a comprehensive solution but rather just a patch aiming
at fixing one particular interaction reported in #2048.

I've left verbose code comments explaining the issue and suggesting
solution in the source code, including:

```
  // TODO: Find general way to manage owned and foreign modal view controllers and refactor this code. Consider building
  // model first (data structue, attempting to be aware of all modals in presentation and some text-like algorithm for
  // computing required operations).
```

Closes #2048
Closes #2085

## Changes

Trigger dissmisal of foreign modal if it is presented above `changeRoot`
modal (last modal that is to stay on stack after the updates).

## Test code and steps to reproduce

`Test2048` in `TestsExample` & `FabricTestExample`.

## Checklist

- [x] Included code example that can be used to test this change
- [x] Ensured that CI passes
ja1ns pushed a commit to WiseOwlTech/react-native-screens that referenced this issue Oct 9, 2024
…ansion#1912)

## Description

Closes software-mansion#1829

Currently it is not possible to navigate to a modal from another modal
view that is mounted in JS under nested stack (see software-mansion#1829 description for
better context).
This is the case, because modal is presented by
`RNSNavigationController` corresponding to the stack under which it is
mounted in JS ==> UIKit reports that such controller is already
presenting.

IMO the last presented modal should be the one, to present new one.


## Changes

Added code handling above case, by checking whether modals from other
stacks are present & using top-most modal for presentation in such case.

## Test code and steps to reproduce

See `Test1829` in test example apps

## Checklist

- [x] Included code example that can be used to test this change
- [x] Ensured that CI passes (merged only comments after final CI
checks)
ja1ns pushed a commit to WiseOwlTech/react-native-screens that referenced this issue Oct 9, 2024
…mansion#2113)

## Description

Basically this is another edition of the issue software-mansion#1829 (handled by software-mansion#1912).
The issue comes down to the fact, that our `ScreenStack` is not aware of
all modal view controllers being in presentation,
but this time it is not aware of third-party modal view controllers
(I've named them "foreign" modals in opposite to "owned" modals).

This PR is not a comprehensive solution but rather just a patch aiming
at fixing one particular interaction reported in software-mansion#2048.

I've left verbose code comments explaining the issue and suggesting
solution in the source code, including:

```
  // TODO: Find general way to manage owned and foreign modal view controllers and refactor this code. Consider building
  // model first (data structue, attempting to be aware of all modals in presentation and some text-like algorithm for
  // computing required operations).
```

Closes software-mansion#2048
Closes software-mansion#2085

## Changes

Trigger dissmisal of foreign modal if it is presented above `changeRoot`
modal (last modal that is to stay on stack after the updates).

## Test code and steps to reproduce

`Test2048` in `TestsExample` & `FabricTestExample`.

## Checklist

- [x] Included code example that can be used to test this change
- [x] Ensured that CI passes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Modal Issue related with iOS modal stack presentation Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants