The Wayback Machine - https://web.archive.org/web/20250305094140/https://github.com/NativeScript/NativeScript/issues/6271
Skip to content

Simplify passing Context from the showModal() method #6271

Open
@tcrgit

Description

When using showModal() to show multiple modals with a new frame to navigate, context does not appear to be passed from page.showModal() function but from the frame.navigate() passed to it.

In the demo example, the second (context) parameter parameter of page.showModal is not passed to the modal page in navigation (excerpted from https://github.com/NativeScript/modal-navigation-demo/)

    const frame = new Frame();
    frame.navigate("modal/modal-page");    
    page.showModal(frame,
        "context", 
        () => console.log("home-page modal frame closed"),
        true);
    );

This results in the modal page having an empty args.context object, and not args.context = "context" as implied.

If a frame is supplied to page.showModal, the frame.navigate() must contain the context, e.g.:

   frame.navigate({moduleName: "modal/modal-page", context: "Context" });
   frame.navigate({moduleName: "modal/modal-page", context: { someContext: "Context", moreContext: "Context2" } });

then in the modal page the context is actually passed, e.g. args.context = "Context" or args.context.someContext = "Context"

Cross reference: NativeScript/modal-navigation-demo#4

This problem appears in both iOS and Android in NativeScript 4.20.

I don't know if this is the new and desired behavior with frame-based modal navigation or if this is a bug in showModal(). At least it is something that should be marked as deprecated.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions