support closing nested modals
This is needed when there are nested modals and therefore multiple props so we can close the nested one
@NorseGaud Can you please explain the use case? I'm having a hard time figuring it out. I would really appreciate some sort of video.
Yeah, nested modals don't close using the hideGlobalModal function
Sorry, can't share anything about my code due to IP, but I can say that the hideSub > oldProps shows:
LOG [{"Component": [Function Component], "hideClose": true, "modalKey": "1706408512865"}, {"Component": [Function Component], "hideClose": false, "modalKey": "1706408514142"}]
This prevents if (oldProps.length === 1) { from doing setIsVisible(false).
Hi @susonthapa, any updates?
Hi @susonthapa, any updates?
Sorry, I didn't get a chance to look into it. I will try to get back to you on weekends.
Hey @susonthapa , just FYI I use this in production successfully.
@NorseGaud Sorry for the late reply, I tested your changes and found some issue. Notice when you click the cancel button in one of the modal it dismisses the entire stack which is obivious from the code changes but I wanted to verify it anyway. Here is a demo video.
Original behavior
https://github.com/susonthapa/react-native-global-modal/assets/33973551/500012dd-fc45-4350-89b7-74539af3122c
With PR changes
https://github.com/susonthapa/react-native-global-modal/assets/33973551/1e9576bd-1b30-4406-a429-85d91104ef51
I won't be merging this PR so feel free to close it or I can close it later.
Thanks @susonthapa, but it has been too long since I've looked at this and I have forgotten even what I did. Regardless, closing the whole stack is not an entirely useless feature. There are some situations I would want this. But there are also situations I would not. Seems like we need to add a way to toggle it and then add the code to not close the stack on nested close, right? Why do you want to block merging the PR and close this instead of fixing it?
Thanks @susonthapa, but it has been too long since I've looked at this and I have forgotten even what I did. Regardless, closing the whole stack is not an entirely useless feature. There are some situations I would want this. But there are also situations I would not. Seems like we need to add a way to toggle it and then add the code to not close the stack on nested close, right? Why do you want to block merging the PR and close this instead of fixing it?
I haven't been able to wrap my head around your use case for nested modals. The whole point of Global Modal is to remove the need for nested modals.
Why do you want to block merging the PR and close this instead of fixing it?
Without more information on the use case, I won't have any idea on what I'm fixing.
Super super confused. Your examples have Nested Modals. When you say "The whole point of Global Modal is to remove the need for nested modals.", then why is there an example for it? It's a valid usecase too. Sometimes I need to generate a yes or no confirmation for an existing modal.
The issue should be fairly clear and you even mentioned it in your reply: "Notice when you click the cancel button in one of the modal it dismisses the entire stack". It should be fairly simple to fix this, but I worry it will be rejected now even if a solution is created.
Sorry if I sound rude, but I agree the example is confusing. The "Nested Modal" in the example shows how you can open a Modal from within the Modal but those are not nested when rendered. The idea is pretty simple, the app renders a single Modal and switches the content to mimic nested Modals.
If you want to close any Modal you can just use "hideGlobalModal" with the key of the modal you want to close. There is also skipQueue flag that you can set which will dismiss the current modal when you want to show another one.
Let me know if this fixes your issue. If you have a valid use case, then feel free to add an example in the sample app and I can take a look into it.