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

How are "present" and "dismiss" methods are intended to be used with BottomSheetModals? #336

Closed
krakz999 opened this issue Mar 9, 2021 · 7 comments
Labels
question Further information is requested

Comments

@krakz999
Copy link

krakz999 commented Mar 9, 2021

Ask your Question

Hello,

So I'm using 2 modals on my screen, and I need to jump from one to the other and vice versa. After reading the documentation, at first I used the dismiss() method on the ref of the currently active modal, and present() on the next modal to switch, which worked, but once I dismissed the modal, I couldn't go back to it (same with close()), present doesn't work on those anymore.

The way it works for me is just calling present() on the modal I want to open, without dismissing. Is this the intended behaviour?

My second issue that is kind of related: When the user was on #1 snap point, went to the second modal, then went back to the first with calling present(), the first modal would be on #0 snap point. I couldn't find a way to present the modal on #1 snap point instead of the default index. (please note in every other scenario my default has to be #0 snap point, but in this specific case I want it to open at #1. Is that currently implemented?

I tried to use snapTo(1) after calling present() which only worked with a timeout, but it doesn't look good.

TLDR for the second: Can you call present() on a modal and animate it to a given snap index fluidly?

@krakz999 krakz999 added the question Further information is requested label Mar 9, 2021
@gorhom
Copy link
Owner

gorhom commented Mar 9, 2021

So I'm using 2 modals on my screen, and I need to jump from one to the other and vice versa. After reading the documentation, at first I used the dismiss() method on the ref of the currently active modal, and present() on the next modal to switch, which worked, but once I dismissed the modal, I couldn't go back to it (same with close()), present doesn't work on those anymore.

The way it works for me is just calling present() on the modal I want to open, without dismissing. Is this the intended behaviour?

you do not need to dismiss the first modal, the library already handle that for you

 present the first modal     ->     present the second modal     ->     dismiss the second modal
                                            |                                        |
                                   first modal will get minimise         first modal will be restored

TLDR for the second: Can you call present() on a modal and animate it to a given snap index fluidly?

you can set index prop and when you call present it will animate to the provided index snap point

@krakz999
Copy link
Author

krakz999 commented Mar 9, 2021

So I'm using 2 modals on my screen, and I need to jump from one to the other and vice versa. After reading the documentation, at first I used the dismiss() method on the ref of the currently active modal, and present() on the next modal to switch, which worked, but once I dismissed the modal, I couldn't go back to it (same with close()), present doesn't work on those anymore.

The way it works for me is just calling present() on the modal I want to open, without dismissing. Is this the intended behaviour?

you do not need to dismiss the first modal, the library already handle that for you

 present the first modal     ->     present the second modal     ->     dismiss the second modal
                                            |                                        |
                                   first modal will get minimise         first modal will be restored

TLDR for the second: Can you call present() on a modal and animate it to a given snap index fluidly?

you can set index prop and when you call present it will animate to the provided index snap point

Thanks. Tried this already but for some reason present doesn't work on neither of the modals once I dismiss them (or when the library dismisses them automatically).

@gorhom
Copy link
Owner

gorhom commented Mar 9, 2021

ahh ,,could you provide a reproducible sample code ? preferable from /examples folder

@krakz999
Copy link
Author

krakz999 commented Mar 10, 2021

So this is the issue I'm having with just using present() to let the library handle the modals automatically, and I'm able to reproduce it in the example project as well.

I have screen "A" and screen "B". I present() screen B from screen A, then I present() screen A from screen B to go back, after a while it stops working.

So what I'm trying to achieve is basically a list screen (screen A) and a details screen (screen B) but navigating between them breaks after a while.

Using the latest v2 of the package.

Screen.Recording.2021-03-10.at.9.35.02.mov

@krakz999
Copy link
Author

krakz999 commented Mar 10, 2021

I've pushed a fix for the stuck modal issue as part of this PR: #337

recording.mov

@gorhom
Copy link
Owner

gorhom commented Mar 10, 2021

there is already pr , which refactor the modal handling #327

@gorhom
Copy link
Owner

gorhom commented Mar 13, 2021

this should be fixed with v2.2.4, feel free to reopen this issue if it still not fixed

@gorhom gorhom closed this as completed Mar 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants