nativescript-windowed-modal icon indicating copy to clipboard operation
nativescript-windowed-modal copied to clipboard

closing a modal window when press the back button

Open PashaArkus opened this issue 6 years ago • 11 comments
trafficstars

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:

  • CLI: 5.3.2
  • Cross-platform modules: 5.4.0
  • Runtime(s): "tns-ios": { "version": "5.2.0" }, "tns-android": { "version": "5.3.1" }
  • Plugin(s): "dependencies": { "@nstudio/nativescript-camera-plus": "^2.1.7", "axios": "^0.18.0", "decode-google-map-polyline": "^1.0.1", "http": "0.0.0", "moment": "^2.24.0", "nativescript-background-http": "^3.4.0", "nativescript-bitmap-factory": "^1.8.1", "nativescript-camera": "^4.4.0", "nativescript-cardview": "^3.1.1", "nativescript-carousel": "^4.1.0", "nativescript-checkbox": "^3.0.3", "nativescript-feedback": "^1.3.9", "nativescript-fonticon": "^2.0.0", "nativescript-geolocation": "^5.0.0", "nativescript-google-maps-sdk": "^2.7.0", "nativescript-loading-indicator": "^2.5.1", "nativescript-material-activityindicator": "^2.2.15", "nativescript-permissions": "^1.3.6", "nativescript-phone": "^1.4.0", "nativescript-platform-css": "^1.6.6", "nativescript-plugin-firebase": "^8.0.1", "nativescript-socketio": "^3.2.1", "nativescript-theme-core": "^1.0.4", "nativescript-ui-gauge": "^3.8.0", "nativescript-ui-sidedrawer": "^6.0.0", "nativescript-vibrate": "^2.1.3", "nativescript-vue": "^2.0.0", "nativescript-windowed-modal": "^5.0.6", "tns-core-modules": "^5.4.0-next-2019-05-01-141636-02", "v-mask": "^1.3.3", "vue-i18n": "^8.9.0", "vuex": "^3.0.1" },

PashaArkus avatar Jun 05 '19 12:06 PashaArkus

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

calebsmithdev avatar Jun 12 '19 13:06 calebsmithdev

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 }); }

PashaArkus avatar Jun 12 '19 14:06 PashaArkus

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.

calebsmithdev avatar Jun 12 '19 14:06 calebsmithdev

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.

edusperoni avatar Jun 12 '19 15:06 edusperoni

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.

budi7 avatar Jun 14 '19 08:06 budi7

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

edusperoni avatar Jun 14 '19 14:06 edusperoni

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

budi7 avatar Jun 15 '19 02:06 budi7

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

edusperoni avatar Jun 18 '19 16:06 edusperoni

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

budi7 avatar Jun 19 '19 08:06 budi7

Thank you @edusperoni

PashaArkus avatar Jun 19 '19 09:06 PashaArkus

@edusperoni longest time! Has this ever been fixed?

alexonozor avatar Dec 02 '22 04:12 alexonozor