Skip to content

Commit

Permalink
fix(popup): [iOS/Droid] not responding
Browse files Browse the repository at this point in the history
  • Loading branch information
ajpinedam committed Apr 8, 2021
1 parent a74cf27 commit 89ef822
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/Uno.UI/UI/Xaml/Controls/Popup/PopupBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ partial void OnChildChangedPartial(UIElement oldChild, UIElement newChild)
provider.Store.ClearValue(provider.Store.TemplatedParentProperty, DependencyPropertyValuePrecedences.Local);
}

UpdateDataContext();
UpdateDataContext(null);
UpdateTemplatedParent();

if (oldChild is FrameworkElement ocfe)
Expand All @@ -98,7 +98,7 @@ protected internal override void OnDataContextChanged(DependencyPropertyChangedE
{
base.OnDataContextChanged(e);

UpdateDataContext();
UpdateDataContext(e);
}

protected internal override void OnTemplatedParentChanged(DependencyPropertyChangedEventArgs e)
Expand All @@ -108,13 +108,21 @@ protected internal override void OnTemplatedParentChanged(DependencyPropertyChan
UpdateTemplatedParent();
}

private void UpdateDataContext()
private void UpdateDataContext(DependencyPropertyChangedEventArgs e)
{
_childHasOwnDataContext = false;
if (Child is IDependencyObjectStoreProvider provider)
{
var dataContextProperty = provider.Store.ReadLocalValue(provider.Store.DataContextProperty);
if (dataContextProperty != null && dataContextProperty != DependencyProperty.UnsetValue)

var shouldClearValue = e != null && e.NewValue == null && dataContextProperty == e.OldValue;
if (shouldClearValue)
{
//In this case we are clearing the DataContext that was previously set by the Popup
//This usually occurs when the owner of the Popup is removed from the Visual Tree
provider.Store.ClearValue(provider.Store.DataContextProperty, DependencyPropertyValuePrecedences.Local);
}
else if (dataContextProperty != null && dataContextProperty != DependencyProperty.UnsetValue)
{
// Child already has locally set DataContext, we shouldn't overwrite it.
_childHasOwnDataContext = true;
Expand Down

0 comments on commit 89ef822

Please sign in to comment.