Browse Source

Do not recalculate pointer popup position on parent moved

Max Katz 4 years ago
parent
commit
9275e59909
1 changed files with 13 additions and 9 deletions
  1. 13 9
      src/Avalonia.Controls/Primitives/Popup.cs

+ 13 - 9
src/Avalonia.Controls/Primitives/Popup.cs

@@ -429,16 +429,20 @@ namespace Avalonia.Controls.Primitives
                     (x, handler) => x.LostFocus += handler,
                     (x, handler) => x.LostFocus -= handler).DisposeWith(handlerCleanup);
 
-                SubscribeToEventHandler<IWindowImpl, Action<PixelPoint>>(window.PlatformImpl, WindowPositionChanged,
-                    (x, handler) => x.PositionChanged += handler,
-                    (x, handler) => x.PositionChanged -= handler).DisposeWith(handlerCleanup);
-                    
-                if (placementTarget is Layoutable layoutTarget)
+                // Recalculate popup position on parent moved/resized, but not if placement was on pointer
+                if (PlacementMode != PlacementMode.Pointer)
                 {
-                    // If the placement target is moved, update the popup position
-                    SubscribeToEventHandler<Layoutable, EventHandler>(layoutTarget, PlacementTargetLayoutUpdated,
-                        (x, handler) => x.LayoutUpdated += handler,
-                        (x, handler) => x.LayoutUpdated -= handler).DisposeWith(handlerCleanup);
+                    SubscribeToEventHandler<IWindowImpl, Action<PixelPoint>>(window.PlatformImpl, WindowPositionChanged,
+                        (x, handler) => x.PositionChanged += handler,
+                        (x, handler) => x.PositionChanged -= handler).DisposeWith(handlerCleanup);
+
+                    if (placementTarget is Layoutable layoutTarget)
+                    {
+                        // If the placement target is moved, update the popup position
+                        SubscribeToEventHandler<Layoutable, EventHandler>(layoutTarget, PlacementTargetLayoutUpdated,
+                            (x, handler) => x.LayoutUpdated += handler,
+                            (x, handler) => x.LayoutUpdated -= handler).DisposeWith(handlerCleanup);
+                    }
                 }
             }
             else if (topLevel is PopupRoot parentPopupRoot)