Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CloseWhenBackgroundIsClicked=True does not work on iOS #41

Closed
tranb3r opened this issue Jan 3, 2023 · 17 comments
Closed

CloseWhenBackgroundIsClicked=True does not work on iOS #41

tranb3r opened this issue Jan 3, 2023 · 17 comments
Assignees

Comments

@tranb3r
Copy link

tranb3r commented Jan 3, 2023

CloseWhenBackgroundIsClicked=True does not work on iOS.
Unless you also set BackgroundInputTransparent=True, but then the click is passed to the element that is visible, which is probably not what you want to do.

On the sample project:

  • the loginPage is ok : CloseWhenBackgroundIsClicked=True and BackgroundInputTransparent=True (no background visible element).
  • the AswinPage is broken : CloseWhenBackgroundIsClicked=True and BackgroundInputTransparent=False (visible elements in background).

No issue on Android.

Could you please take a look?
Thanks

@LuckyDucko LuckyDucko self-assigned this Jan 4, 2023
@jakob-reesalu
Copy link

Got the same problem here!

@jpsaccount
Copy link

Got the same problem. Any updates?

@Sumn3rd
Copy link

Sumn3rd commented Jan 11, 2023

Finding the same problem on Windows.

Interesting enough if you set: CloseWhenBackgroundIsClicked to false; & InputTransparent to true, it allows the clickthrough to background at the cost of losing access to content on the popup.

Inside version 1.1.0 It would seem that: BackgroundClickedCommand is always null inside popup.cs - meaning the if CanExecute condition is never true, preventing the command to fire but stopping the null exception.

@LuckyDucko
Copy link
Owner

Found a simple fix for iOS which I will add.

In the iOS mopups section, we have the "PopupWindow" file.

This file is used so we can hook and override the HitTest function of a popupwindow, so we can determine if the popupwindow was hit or not.

When it determines if it should send a background click, I just added in an extra check for CloseWhenBackgroundIsClicked, so it should sort out the iOS one.

Windows I dont have access to a windows computer right now to poke at, but in PopupPageRenderer there is the following screenshot, I would toy around with that, as it is attached to the pointer pressed event.
Screenshot 2023-01-12 at 10 27 44

@LuckyDucko
Copy link
Owner

@tranb3r
@jakob-reesalu
@jpsaccount

If you guys want to download the repo, and link Mopups to your app instead of using the nugget, could verify if you believe its a fix for the issue.

@PaulMDemers
Copy link
Contributor

PaulMDemers commented Jan 13, 2023

I am also experiencing the issue under MacCatalyst.

@tranb3r
Copy link
Author

tranb3r commented Jan 13, 2023

@LuckyDucko
It now behaves like if BackgroundInputTransparent is always True, which is probably not what we want, is it?

@LuckyDucko
Copy link
Owner

It does? I'll do some more testing, but i did test and and could confirm there is a difference between the two.

@tranb3r
Copy link
Author

tranb3r commented Jan 14, 2023

I've tested the sample AswinPage, on iOS, and when I click on the background, the popup does close now, but the click is propagated to the element behind, even if BackgrouInputTransparent is false.

@vccosenza
Copy link

someone already mentioned this but the issue exists in Mac catalyst as well. Other than the CloseWhenBackGroundClicked issue, these popups work much nicer than the community toolkit for my apps needs. Could we get a Mac catalyst fix?

@LuckyDucko
Copy link
Owner

@tranb3r

Give it one more test, I did a more in depth dive.

it turns out that when I perform a a HitTest, if you return null to that hit test, under the hood iOS attempts to find the next ui interact-able element to fire off, which is why the previous fix wasn't working.

@vccosenza & @PaulMDemers

I added the same fix to MacCatayst, however, on my computer MacCatalyst seems broken? is it just the sample app that works this way?

@vccosenza
Copy link

@LuckyDucko In the latest of the sample app, I am seeing Mac catalyst close instantly after the popup opens. The latest Nuget version I have installed in my project though this is not the case and works really well other than the background close issue

@tranb3r
Copy link
Author

tranb3r commented Jan 16, 2023

@tranb3r
Give it one more test, I did a more in depth dive.

Yes, it think it works now. Thanks!

@PaulMDemers
Copy link
Contributor

PaulMDemers commented Jan 16, 2023

Just tested the sample app on Catalyst, the windows do appear and disappear. However they appear to move as soon as the mouse moves and are not waiting for a click.

Click, no mouse move -> shows -> mouse move -> vanishes

Poking the code a bit, it looks like HitTest() is being called for the mouse movement events.

@PaulMDemers
Copy link
Contributor

PaulMDemers commented Jan 16, 2023

I modified the HitTest function in the MacCatalyst PopupWindow.

Changed:
formsElement.SendBackgroundClick();

to:
if(uievent?.ButtonMask != 0)
formsElement.SendBackgroundClick();

On line 40, this appears to correct the issue for me.

@LuckyDucko
Copy link
Owner

Thanks guys, sorted on latest release https://github.com/LuckyDucko/Mopups/releases/tag/v1.1.1

@RichardMarsh
Copy link

Thank you for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants