Nativescript: [Bug] Content outside Frame disappears after opening and closing a modal in iOS

Created on 29 May 2019  路  4Comments  路  Source: NativeScript/NativeScript

Environment

  • CLI: 5.4.0
  • Cross-platform modules: 5.4.2
  • iOS Runtime: 5.4.0

Describe the bug
On iOS, the content placed outside the Frame disappears after you open and close a modal.

To Reproduce
Try the provided playground app on iOS and open a modal and close it. You will see that the red area disappears. But this doesn't happen on Android.

Expected behavior
Expect it to behave the same as it does on Android.
The content outside the Frame should remain intact

Sample project
https://play.nativescript.org/?template=play-js&id=4Mbqoc&v=35


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

bug ios high

All 4 comments

For anyone facing this issue, here's a workaround,
https://play.nativescript.org/?template=play-js&id=4Mbqoc&v=37

Open the modal using Frame's parent.

There is a known side effect to the above approach,

When you show modals in the regular way, the page from which you show modal, does not get unloaded or fire any of the navigation life-cycle events.

But with the suggested work-around,
the page which you are working with, will fire "unloaded", "navigatingFrom" when the modal opens,

and when the modal closes, the page will fire "loaded"

it is easy to maintain a variable to check if modal was shown, and then ignore these events.

showingModally = true;
getFrameById('rootFrame').parent.showModal({
   ...
   function closeCallback() {
        setTimeout(() => {
           // this timeout helps ignore the page loaded event
           showingModally = false;
       }, 500);
  }
})

Then in the respective events just return if showingModally is true

pageLoaded() {
   if (showingModally) return;
   ....
}
navigatingFrom() {
   if (showingModally) return;
   ....
}
unloaded() {
   if (showingModally) return;
   ....
}

This playground sample demonstrates this behavior,
Open Modal button uses the work-around approach

Open Modal (from viewModal) uses the regular approach
https://play.nativescript.org/?template=play-js&id=4Mbqoc&v=38

Hi is there any fixes for it?

Hi @KonstantinObuhov,
Check out the provided workaround above.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NickIliev picture NickIliev  路  3Comments

guillaume-roy picture guillaume-roy  路  3Comments

dhanalakshmitawwa picture dhanalakshmitawwa  路  3Comments

Pourya8366 picture Pourya8366  路  3Comments

rogangriffin picture rogangriffin  路  3Comments