We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Popup closes immediatly when opened in OnAppearing

Hi

I've created a method to show a modal message box with SfPopupLayout in code. This Popup is opened sometimes after popping a page from the navigationstack. I handle this in the OnAppearing method of the now top page of the navigationstack. Unfortunatly, the popup is shown for just a fraction of a second and then removed.

I haven't found any later event to handle this. Does anyone have an idea how to keep that popup open or where the appropriate position for the call would be?

The code I'm using for the popup:

public void ShowMessageBox(
      string sMessage,
      string sOkText,
      Command okCommand = null,
      string sCancelText = null,
      Command cancelCommand = null)
    {
      var msgBox = new SfPopupLayout();

      msgBox.PopupView.AcceptButtonText = sOkText;
      if(!String.IsNullOrEmpty(sCancelText))
      {
        msgBox.PopupView.AppearanceMode = AppearanceMode.TwoButton;
        msgBox.PopupView.DeclineButtonText = sCancelText;
      }

      if (okCommand != null)
        msgBox.PopupView.AcceptCommand = okCommand;

      if (cancelCommand != null)
        msgBox.PopupView.DeclineCommand = cancelCommand;

      msgBox.PopupView.PopupStyle.CornerRadius = 10;
      msgBox.PopupView.ShowHeader = false;
      msgBox.PopupView.ShowCloseButton = false;
      msgBox.PopupView.AutoSizeMode = AutoSizeMode.Height;

      var contentTemplateView = new DataTemplate(() =>
       {
         var lbl = new Label();
         lbl.Margin = new Thickness(5, 10);
         lbl.Text = sMessage;
         lbl.LineBreakMode = LineBreakMode.WordWrap;
         lbl.WidthRequest = 260;

         var stack = new StackLayout();
         stack.Children.Add(lbl);
         return stack;
       });

      msgBox.PopupView.ContentTemplate = contentTemplateView;

      /// Makes the Message modal
      msgBox.StaysOpen = true;
      msgBox.IsOpen = true;
      msgBox.Show(false);
    }


12 Replies

BS Balasubramani Sundaram Syncfusion Team August 30, 2019 08:00 PM UTC

Hi Martin,  
 
Thank you for contacting Syncfusion support.     

 
Based on your code snippet we have checked the issue “Popup closes immediately when opened in On Appearing”. We have checked the issue in UWP platform we didn’t get any issue its working fine in our side but when we have checked in android platform, we faced a same issue when we forth back to pervious page within the Navigation Page. We have prepared a sample based on your provided details please confirm whether you are trying to convey the same this will be more help us to provide a solution at earliest. 
 
Please refer the following sample, 
 
 
Regards,
Balasubramani Sundaram. 



MA Martin September 3, 2019 08:31 AM UTC

Hello,

while in my case I've routed everything into the ViewModel and I actively pop the second page, the behaviour in your sample project when coming back to the first page is exactly the same as what I am experiencing. I found a workaround by starting a thread that delays for 500 ms before opening the popup, but not needing this rather hacky solution would be nice.

greets
Martin


BS Balasubramani Sundaram Syncfusion Team September 4, 2019 11:59 AM UTC

Hi Martin,  
 
Thank you for the update.  
 
We have already fixed the issue “Popup closes immediately when opened in On Appearing” and the issue fix will be included in our upcoming 2019 Volume 3 Beta release which is expected to be roll out by mid of September 2019. Please let us know if you required a patch earlier.   
    
We appreciate your patience until then.   
  
Regards,  
Balasubramani Sundaram. 



LM Luke McNally May 7, 2020 07:56 AM UTC

Please can you confirm the bug ID and what build the fix actually went into? We're running 17.4.0.53 and are still experiencing the issue on Android. I've reviewed the release notes for 2020 Volume 1 and can't see any mention of it being fixed in there.


KK Karthikraja Kalaimani Syncfusion Team May 8, 2020 12:46 PM UTC

Hi Luke,

We have logged that bug as internally and included the fix in the version 17.3.0.26. So only the we did not mention the bug in release update. Moreover, we have checked the reported issue in SfPopupLayout version 17.4.0.53 and we could not able to reproduce the issue in our end and it is working fine as expected. Since we are not about your exact application scenario. So could you please reproduce the issue in the below attached sample and revert us back with clear replication procedure.

Sample link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/Popup_Demo96799049-1530933884.zip

Regards,
Karthik Raja 



PP Paul Parkins October 4, 2022 09:46 AM UTC

Hi,

I believe we are experiencing a similar problem in our Android app which is using SyncFusion.Forms v20.2.0.40. So I took the sample from your last post, and it too appears to demonstrate a problem even when I upgrade it to the latest Xamarin.Forms v5 and Syncfusion 20.3.0.47 packages.


Although your sample application was showing pop-up boxes, it wasn't obvious to me what it should be doing and when. So in my version I have added debugging statements to the Output window. Please see the attached revised version (Android only). This is what I have changed:

  • The navigation button text
  • Uses of Debug.Writeline to output to the Output window to indetify the navigation flow, and occurrence of IsAppearing, etc.
  • Removed iOS and UWP projects
  • Updated Xamarin.Forms 5.0.0.2515 (latest)
  • Updated both Syncfusion packages to 20.3.047 (latest)
  • Had to comment our the XamlCTask section inXamarin.Formed.targets. I have no idea about this as I have never come across it before, but it would not compile with this present after I had upgrade to Xamarin Forms 5

To demonstrate the problem using this version of your app (or in your original):
  • Build and run the application (Android Emulator for Pixel 5 is fine)
  • Demo page is displayed, (demo page) popup is visible
  • Press "Done" to close the pop-up
  • Click the button to navigate to main page
  • Main page is displayed, (main page) popup is visible
  • Press "Done" to close the pop-up
  • Press the Navigation back button to return from Main Page to Demo Page
  • Demo page is displayed and the (demo page) popup is visible for about a second and then disappears.
Why is the pop-up disappearing? It would seem that the popup's Closed handler is being called. The call stack only shows "External Code".


In our own code we are using MVVM and the IsOpen property is bound to a PopupOpen property in the page model (also the Stays Open property is set to true). We are showing the pop-up and temporarily setting PopupOpen to false whilst we show a different page by pushing onto the navigation stack. When we return to our popup form, we set PopupOpen to true in IsAppearing, but we find it shows briefly then disappears in the same way the demo application experiences.  We have found that adding a 500ms delay helps, but this is not very scientific, and the delay period needed could vary with device speed.

Thanks

Paul

Attachment: SfPopup_Demo_bf84a239.zip


PP Paul Parkins October 4, 2022 03:48 PM UTC

Hi

Your response does not make any sense

  1. What does "logged that bug as inside" mean?
  2. What is the "astroluna" fix mean, and how do it affect this? Your link took me to a page in Spanish
  3. Why are you talking about 17.3.0.26 and 17.4.0.53?  I told you I updated your sample to use the very latest 20.3.0.47 package, in which I believe there is still a bug
  4. I already provided a version of your own application that demonstrates the problem, though I believe you could also see this on your own version without my updates
  5. I already provided you a clear and concise list of instruction to reproduce the problem
  6. I also explained a bit about my actual application.

Please re-read and digest my previous post.

Paul


PP Paul Parkins October 4, 2022 03:50 PM UTC

Or maybe that reply wasn't meant for me at all since you have responded "Hello jahanzaib,".

Perhaps you have your support threads mixed up?


Paul



SV Suja Venkatesan Syncfusion Team October 5, 2022 02:49 PM UTC

Hi Paul,


Regarding issue “SfPopup dismissed when opening from OnAppearing while navigate back


We would like let you know that we are able to replicate the reported scenario in Xamarin.Forms.Android platform. Currently, we are validating the reported scenario in our source level. We will update you with further details on or before October 7, 2022. We appreciate your patience until then.


Regarding “Or maybe that reply wasn't meant for me at all since you have responded "Hello jahanzaib,".

Perhaps you have your support threads mixed up? “


We would like to inform you that was spam content and we have removed it now.


Regards,

Suja



SV Suja Venkatesan Syncfusion Team October 7, 2022 02:23 PM UTC

Hi Peter,


We have logged a bug report for the reported issue “SfPopup gets dismissed immediately when opened from OnAppearing ". We will fix the issue and include the fix in our weekly nuget which is scheduled on November 1, 2022. We will let you know once it is released with the fix. You can also track the status of the report from the below link.  


Feedback Link : https://www.syncfusion.com/feedback/38270/sfpopup-gets-dismissed-immediately-when-opened-from-onappearing


Disclaimer: Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.


Regards,

Suja



SV Suja Venkatesan Syncfusion Team November 3, 2022 01:31 PM UTC

Due to the 2022 volume 3 SP release on November 7, 2022, The Weekly NuGet release is not rolling out as we promised. The fix will be available in our upcoming 2022 volume 3 SP release.



SV Suja Venkatesan Syncfusion Team November 9, 2022 02:27 PM UTC

We are glad to announce that our Essential Studio 2022 Volume 3 Service Pack Release V20.3.0.56 is rolled out with fix for the issue "SfPopup gets dismissed immediately when opened from OnAppearing” and it is available for download under the following link.


https://www.syncfusion.com/forums/178709/essential-studio-2022-volume-3-service-pack-release-v20-3-0-56-is-available-for-download


We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.



Loader.
Live Chat Icon For mobile
Up arrow icon