Skip to content

Commit 9f8b3af

Browse files
committed
fix: Propagate focus property changes from PopupBase to Child
1 parent 7cac6bc commit 9f8b3af

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/Uno.UI/UI/Xaml/Controls/Popup/PopupBase.cs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
2+
using Uno.UI;
53
using Windows.Foundation;
64
using Windows.UI.Xaml.Input;
7-
using Uno.Extensions;
8-
using Uno.UI.DataBinding;
95
using Windows.UI.Xaml.Media;
10-
using Uno.UI;
116
#if XAMARIN_IOS
127
using CoreGraphics;
138
using UIKit;
@@ -31,6 +26,17 @@ public partial class PopupBase : FrameworkElement, IPopup
3126
/// </summary>
3227
internal IDynamicPopupLayouter CustomLayouter { get; set; }
3328

29+
internal override void OnPropertyChanged2(DependencyPropertyChangedEventArgs args)
30+
{
31+
if (args.Property == AllowFocusOnInteractionProperty ||
32+
args.Property == AllowFocusWhenDisabledProperty)
33+
{
34+
PropagateFocusProperties();
35+
}
36+
37+
base.OnPropertyChanged2(args);
38+
}
39+
3440
private protected override void OnUnloaded()
3541
{
3642
IsOpen = false;
@@ -71,10 +77,13 @@ partial void OnChildChangedPartial(UIElement oldChild, UIElement newChild)
7177
{
7278
provider.Store.ClearValue(provider.Store.DataContextProperty, DependencyPropertyValuePrecedences.Local);
7379
provider.Store.ClearValue(provider.Store.TemplatedParentProperty, DependencyPropertyValuePrecedences.Local);
80+
provider.Store.ClearValue(AllowFocusOnInteractionProperty, DependencyPropertyValuePrecedences.Local);
81+
provider.Store.ClearValue(AllowFocusWhenDisabledProperty, DependencyPropertyValuePrecedences.Local);
7482
}
7583

7684
UpdateDataContext(null);
7785
UpdateTemplatedParent();
86+
PropagateFocusProperties();
7887

7988
if (oldChild is FrameworkElement ocfe)
8089
{
@@ -142,6 +151,15 @@ private void UpdateTemplatedParent()
142151
}
143152
}
144153

154+
private void PropagateFocusProperties()
155+
{
156+
if (Child is IDependencyObjectStoreProvider provider)
157+
{
158+
provider.Store.SetValue(AllowFocusOnInteractionProperty, AllowFocusOnInteraction, DependencyPropertyValuePrecedences.Local);
159+
provider.Store.SetValue(AllowFocusWhenDisabledProperty, AllowFocusWhenDisabled, DependencyPropertyValuePrecedences.Local);
160+
}
161+
}
162+
145163
/// <summary>
146164
/// A layouter responsible to layout the content of a popup at the right place
147165
/// </summary>

0 commit comments

Comments
 (0)