mukaschultze / nativescript-windowed-modal

Consistent modals for Android and iOS
https://www.npmjs.com/package/nativescript-windowed-modal
Apache License 2.0
47 stars 18 forks source link

closing a modal window when press the back button #8

Open PashaArkus opened 5 years ago

PashaArkus commented 5 years ago

How to cancel / disable closing the modal window when you press the back button?

Which platform(s) does your issue occur on?

Android

Please, provide the following version numbers that your issue occurs with:

calebsmithdev commented 5 years ago

This is a typical modal, so you wouldn't need to do anything more than this.$navigateBack(), or following the docs from here if you $showModal: https://nativescript-vue.org/en/docs/routing/manual-routing/#showmodal

PashaArkus commented 5 years ago

So it is, this is a standard modal window, but I cannot stop the standard behavior of the window when I press the back button. The window of simplicity closes, but I need it to not close. I use the following code to listen to the back button event, but it works only after the user presses the back button when the window is already closed. if (Platform.isAndroid) { application.android.on(AndroidApplication.activityBackPressedEvent, (data) => { data.cancel = true }); }

calebsmithdev commented 5 years ago

Shoot sorry! I totally read that as you wanted to close the modal. I tried something at one point.. let me see if I can find that in my code somewhere.

edusperoni commented 5 years ago

Shouldn't this issue be in the Nativescript core repo? Doesn't seem an issue with this plugin specifically.

We actually had a issue where we were using data.cancel = true and it was preventing the closing of modals, so I'm not sure why it's behaving the other way around for you.

budi7 commented 5 years ago

Hi all... i'm currently facing the same problem as @PashaArkus. i setted the data.cancel = true and won't prevent modal from closing.

hopefully if you guys want to add this feature, it will be very helpful for some cases. Especially when we need to focus our modal and prevent user from interacting anywhere else except our modal.

edusperoni commented 5 years ago

Is this issue reproducible without this plugin installed? If so, I'll close this issue and ask you to please open an issue in https://github.com/nativescript/nativescript

budi7 commented 5 years ago

hi @edusperoni thanks for following up this issue... i've tested without this plugin, an activityBackPressedEvent is triggered, and sets the data.cancel = true will prevent modal from closing.

I'm using nativescript vue v2 and nativescript v 5.4.1

** reference: https://github.com/NativeScript/NativeScript/pull/6261

edusperoni commented 5 years ago

We've identified the issue and are working to fix it. We're also thinking about creating a separate showTransparentModal instead of monkey-patching showModal, so there might be a breaking change in the next version

budi7 commented 5 years ago

I'm gonna looking forward for next version sir. Thank you @edusperoni

PashaArkus commented 5 years ago

Thank you @edusperoni

alexonozor commented 1 year ago

@edusperoni longest time! Has this ever been fixed?