Skip to content

Conversation

@TheCodeTraveler
Copy link
Collaborator

@TheCodeTraveler TheCodeTraveler commented Jun 20, 2025

Description of Change

This PR adds the bindable property public bool CanBeDismissedByTappingOutsideOfPopup { get; set } to Popup.

This PR also updates the logic in PopupPage to only dismiss a Popup when both Popup.CanBeDismissedByTappingOutsideOfPopup and IPopupOptions.CanBeDismissedByTappingOutsideOfPopup are true:

// Only dismiss when a user taps outside Popup when **both** Popup.CanBeDismissedByTappingOutsideOfPopup and PopupOptions.CanBeDismissedByTappingOutsideOfPopup are true
// If either value is false, do not dismiss Popup
static bool GetCanBeDismissedByTappingOutsideOfPopup(in Popup popup, in IPopupOptions popupOptions) => popup.CanBeDismissedByTappingOutsideOfPopup & popupOptions.CanBeDismissedByTappingOutsideOfPopup;

Linked Issues

PR Checklist

Additional Information

This feature allows developers to subclass from Popup and create a reusable Popup that cannot be dismissed when the user taps outside of Popup:

class UndismissablePopup : Popup
{
    public UndismissablePopup()
    {
        CanBeDismissedByTappingOutsideOfPopup = false;
    }
}

@TheCodeTraveler TheCodeTraveler added the pending documentation This feature requires documentation label Jun 20, 2025
Copy link
Contributor

Copilot AI left a 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 introduces the bindable property CanBeDismissedByTappingOutsideOfPopup to the Popup control and updates dismissal logic so that a popup is only dismissed when both Popup.CanBeDismissedByTappingOutsideOfPopup and IPopupOptions.CanBeDismissedByTappingOutsideOfPopup are true. Key changes include:

  • Adding the bindable property and XML documentation for CanBeDismissedByTappingOutsideOfPopup in Popup.shared.cs.
  • Refactoring PopupPage.shared.cs to use a new helper method for evaluating the dismissal condition.
  • Adding unit tests to verify the tap gesture recognizer behavior when the property values vary.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/CommunityToolkit.Maui/Views/Popup/PopupPage.shared.cs Updates to dismissal logic and event handlers using GetCanBeDismissedByTappingOutsideOfPopup.
src/CommunityToolkit.Maui/Views/Popup/Popup.shared.cs New bindable property for CanBeDismissedByTappingOutsideOfPopup with XML documentation.
src/CommunityToolkit.Maui/Primitives/Defaults/PopupDefaults.shared.cs Added default constant for CanBeDismissedByTappingOutsideOfPopup.
src/CommunityToolkit.Maui.UnitTests/Views/Popup/PopupPageTests.cs New test verifying that the tap gesture recognizer respects both dismissal conditions.

Copy link
Contributor

@bijington bijington left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @TheCodeTraveler I just added a comment to the copilot point regarding bitwise otherwise this looks good!

@TheCodeTraveler TheCodeTraveler merged commit 98449fc into main Jun 20, 2025
15 of 16 checks passed
@TheCodeTraveler TheCodeTraveler deleted the Add-CanBeDismissedByTappingOutsideOfPopup-to-Popup branch June 20, 2025 21:18
@github-actions github-actions bot locked and limited conversation to collaborators Jun 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

pending documentation This feature requires documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants