NativeScript/NativeScript

Simplify passing Context from the showModal() method

Open

#6,271 opened on 2018年9月14日

GitHub で見る
 (6 comments) (0 reactions) (1 assignee)TypeScript (23,592 stars) (1,634 forks)batch import
featuregood first issuehacktoberfestmodal-page

説明

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: https://github.com/NativeScript/modal-navigation-demo/issues/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.

コントリビューターガイド