Skip to content

Variety of bugs with ModalDialogService.showModal and navigation #1661

Open
@daveware-nv

Description

@daveware-nv

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI:
  • Cross-platform modules: 5.0.5 (tns-core-modules)
  • Android Runtime: 5.0.0
  • iOS Runtime: N/A (haven't tested iOS)
  • NativeScript-Angular: 7.0.3
  • Angular: 7.0.4

Describe the bug
With page-router-outlet:

  • Closing a modal that was opened on a page navigated to with skipLocationChange: true, will cause a navigate to the previous page
  • Closing a modal that was opened on a page navigated to with replaceUrl: true, will cause a navigate to the previous page
  • RouterExtensions.canGoBack() returns true on a freshly opened modal. RouterExtensions.back() will then do nothing, except calling ModalDialogParams.closeCallback() with no longer close the dialog

With router-outlet:

  • RouterExtensions.canGoBack() will cause a crash within the modal, and after the modal closes until a navigation action is performed. (TypeError: Cannot read property 'states' of undefined File: "file:///data/data/org.nativescript.nstest/files/app/tns_modules/nativescript-angular/router/ns-location-strategy.js, line: 227, column: 22)

To Reproduce
As above, depending on the bug

Expected behavior

  • No navigation should ever occur when closing a modal, the page that the modal was open from should be there, unchanged.
  • RouterExtensions.canGoBack() should never crash
  • RouterExtensions.back() shouldn't break the modal closing functionality

Sample project

https://play.nativescript.org/?template=play-ng&id=oXY9vP&v=3

This is setup for the page-router-outlet cases, unfortunately I haven't tested this 'play' since I don't have a device with the app installed on it, I tried to copy the relevant bits from my local test app though. So it should be close. It has three pages with buttons for moving forward between them. The android back button is being redirected to RouterExtensions.back() (see app.component.ts)

You'll have to change the page-router-outlet to router-outlet to test that bit (don't forget to add {createFrameOnBootstrap: true} to the bootstrap)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions