Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Desktop] DragStarting called on parent control rather than on child control #18765

Open
kucint opened this issue Nov 11, 2024 · 0 comments · May be fixed by #18795
Open

[Desktop] DragStarting called on parent control rather than on child control #18765

kucint opened this issue Nov 11, 2024 · 0 comments · May be fixed by #18795
Assignees
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification

Comments

@kucint
Copy link

kucint commented Nov 11, 2024

Current behavior

This bug is present only on Desktop Framework, WinAppSDK works fine.

Create an UIElement that contains another UIElement.

image

Both of them have DragStarting event handler attached.
Bug: When the child is being dragged, the parent's handler is called rather than child's one.

<Page x:Class="UnoDragStartingApp.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="using:UnoDragStartingApp"
      Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Frame
        BorderThickness="1"
        BorderBrush="Black"
        Background="LightCoral"
        Width="400"
        Height="300"
        HorizontalAlignment="Center"
        VerticalAlignment="Center"
        CanDrag="True"
        DragStarting="Frame_DragStarting">
        <Rectangle
            Fill="LightBlue"
            Stroke="Black"
            StrokeThickness="1"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Width="100"
            Height="80"
            CanDrag="True"
            DragStarting="Rectangle_DragStarting"/>
    </Frame>
</Page>
public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();
    }

    private void Frame_DragStarting(UIElement sender, DragStartingEventArgs args)
        => Debug.WriteLine("Frame_DragStarting");

    private void Rectangle_DragStarting(UIElement sender, DragStartingEventArgs args)
        => Debug.WriteLine("Rectangle_DragStarting");
}

I suppose, the same incorrect behavior is to be observed on others handlers like:

  • DropCompleted
  • DragEnter
  • DragLeave
  • PointerReleased
  • ... other

Expected behavior

When the child element is being dragged, the child's handler shall be called rather than parent's one.

How to reproduce it (as minimally and precisely as possible)

MINIMAL REPRO PROJECT: UnoDragStartingApp.zip

STEPS TO REPRODUCE:

  • run the App under Desktop Framework
  • drag child element.
  • observe that Frame_DragStarting method is called, expected Rectangle_DragStarting method is called

Workaround

No response

Works on UWP/WinUI

Yes

Environment

No response

NuGet package version(s)

"Uno.Sdk": "5.5.32"

Affected platforms

Skia (WPF)

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

@kucint kucint added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification
Projects
None yet
2 participants