Skip to content

Commit

Permalink
fix: Adjust IsFocusable on Popup
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Oct 5, 2024
1 parent 8b6a5d3 commit 228d4a1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/Popup/Popup.Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ partial void OnIsOpenChangedPartial(bool oldIsOpen, bool newIsOpen)
Focus(FocusState.Programmatic);
}
}

if (IsLightDismissEnabled || IsForFlyout)
{
m_fIsLightDismiss = true;
}
}
else
{
Expand All @@ -123,6 +128,8 @@ partial void OnIsOpenChangedPartial(bool oldIsOpen, bool newIsOpen)
_lastFocusedElement = null;
}
}

m_fIsLightDismiss = false;
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/Uno.UI/UI/Xaml/Controls/Popup/Popup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,4 @@ internal Brush LightDismissOverlayBackground

internal static DependencyProperty LightDismissOverlayBackgroundProperty { get; } =
DependencyProperty.Register(nameof(LightDismissOverlayBackground), typeof(Brush), typeof(Popup), new FrameworkPropertyMetadata(defaultValue: null, propertyChangedCallback: (o, e) => ((Popup)o).ApplyLightDismissOverlayMode()));

// On WinUi, a popup is not IsTabStop but is somehow focusable. This is a workaround to match that behaviour.
internal override bool IsFocusableForFocusEngagement() => true;
}
18 changes: 18 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/Popup/Popup.h.mux.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Microsoft.UI.Xaml.Controls.Primitives;

public partial class Popup
{
private bool m_fIsLightDismiss;

internal override bool IsFocusable =>
m_fIsLightDismiss &&
IsVisible() &&
IsEnabledInternal() &&
AreAllAncestorsVisible();
}

0 comments on commit 228d4a1

Please sign in to comment.