-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Catalyst] WebView does not display ContextFlyout on right-click - fix #30309
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses a context menu display issue on Catalyst by ensuring right-click events on a WKWebView are intercepted appropriately.
- Adds a mask view to WKWebView to intercept right-clicks and pass them to the context menu interaction.
- Defines a custom InterceptRightClickWebViewMaskView class with an overridden HitTest to handle secondary (right-click) events.
// If the view is a WKWebView, we need to intercept right-clicks | ||
// to show the context menu, so we add a mask view that intercepts | ||
// right-clicks and passes them to the context menu interaction. | ||
var maskView = new InterceptRightClickWebViewMaskView(uiView.Bounds) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mask view created for WKWebView is never removed when the context flyout is cleared. Consider adding logic to remove the mask view to prevent potential memory leaks or interference with later interactions.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you include a test? On UITest can use a method to always right click in a specific coordinates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See Javiers comment!
Hi @@kubaflo. We have added the "s/pr-needs-author-input" label to this issue, which indicates that we have an open question/action for you before we can take further action. This PRwill be closed automatically in 14 days if we do not hear back from you by then - please feel free to re-open it if you come back to this PR after that time. |
Done |
Let me know if we want to proceed with this pr :) If so then I will include a test |
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
Note: This approach adds a transparent mask view over the WKWebView to intercept right-click events and display the MAUI ContextFlyout. As a result, this intentionally blocks the default WKWebView context menus on right-click.
Issues Fixed
Fixes #30308
The demo can be found here
Screen.Recording.2025-06-30.at.01.59.28.mov
Screen.Recording.2025-06-30.at.01.58.12.mov