Environment
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.
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.