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

Drag Drop outside window broken with 1.5-preview1 #9360

Closed
stevenbrix opened this issue Feb 23, 2024 · 9 comments
Closed

Drag Drop outside window broken with 1.5-preview1 #9360

stevenbrix opened this issue Feb 23, 2024 · 9 comments
Labels
area-DragAndDrop bug Something isn't working closed-Fixed Described behavior has been fixed. Regression team-CompInput Issue for IXP (Composition, Input) team
Milestone

Comments

@stevenbrix
Copy link
Contributor

stevenbrix commented Feb 23, 2024

Describe the bug

When a user drags outside of our app, we create a transparent window which follows the mouse pointer and is used to allow people to drag tabs to a new window. This worked well in 1.4, but is now broken in 1.5 preview. The simple act of creating a window (doesn't even need to be shown) breaks the app

Steps to reproduce the bug

  1. Create new winui3 project
  2. Replace MainWindow.xaml with:
<Window
    x:Class="WinUI3Test.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:WinUI3Test"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Background="Black">
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
            <TextBlock Text="DragMe" CanDrag="True" DragStarting="TextBlock_DragStarting"/>
        </StackPanel>
    </Grid>

</Window>
  1. Replace MainWindow.xaml.cs with:
    public sealed partial class MainWindow : Window
    {
        public MainWindow()
        {
            this.InitializeComponent();
            Content.DragLeave += Content_DragLeave;
            Content.DragOver += Content_DragOver;
            Content.AllowDrop = true;
        }

        private void Content_DragOver(object sender, DragEventArgs e)
        {
            e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
        }

        private Window placeholderWindow;
        private void Content_DragLeave(object sender, DragEventArgs e)
        {
            if (placeholderWindow == null) {
                placeholderWindow = new Window();
            }
        }

        private void TextBlock_DragStarting(UIElement sender, DragStartingEventArgs args)
        {
            args.AllowedOperations = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
        }
    }
4. F5 the app
5. Drag the text block labeled "Drag Me" outside of the window

Expected behavior

I can continue the drag operation

Screenshots

winuidragbork.mp4

NuGet package version

WinUI 3 - Windows App SDK 1.5 Preview 1: 1.5.240205001-preview1

Windows version

Windows 11 (22H2): Build 22621

Additional context

It's the simple act of creating the window that causes things to stop working. If you comment out placeholderWindow = new Window(); then the drag continues to work

@stevenbrix stevenbrix added the bug Something isn't working label Feb 23, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Feb 23, 2024
@bpulliam bpulliam added team-Markup Issue for the Markup team area-DragAndDrop and removed needs-triage Issue needs to be triaged by the area owners labels Feb 23, 2024
@stevenbrix
Copy link
Contributor Author

stevenbrix commented Feb 23, 2024

some more context, while more inconsistent, i can repro this bug without having to leave the bounds of the window.

winuidragbork2.mp4

here's the updated MainWindow.xaml.cs for this:

    public sealed partial class MainWindow : Window
    {
        public MainWindow()
        {
            this.InitializeComponent();
            Content.DragLeave += Content_DragLeave;
            Content.DragOver += Content_DragOver;
            Content.AllowDrop = true;
            Content.Drop += Content_Drop;
        }

        private void Content_Drop(object sender, DragEventArgs e)
        {
            placeholderWindow = null;
        }

        private void Content_DragOver(object sender, DragEventArgs e)
        {
            e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
        }

        private Window placeholderWindow;
        private void Content_DragLeave(object sender, DragEventArgs e)
        {
            if (placeholderWindow == null) {
               placeholderWindow = new Window();
            }
        }

        private void TextBlock_DragStarting(UIElement sender, DragStartingEventArgs args)
        {
            args.AllowedOperations = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
            if (placeholderWindow == null) {
                placeholderWindow = new Window();
            }
        }

    }

EDIT: this repro only seems to be caused by the in-app toolbar

@kmgallahan
Copy link
Contributor

If you disable the 'In-app Toolbar' it doesn't seem to repro. Probably related to #8806 which is reported as fixed in 1.5 release candidate (not available yet).

@stevenbrix
Copy link
Contributor Author

that only seems to affect the second repro i gave. the first one still reproes without the in app toolbar. we see this in our app and we don't us VS for debugging

@JochemPalmsens
Copy link

1.5.240227000

@bpulliam
Copy link
Contributor

bpulliam commented Mar 4, 2024

@JochemPalmsens, does that mean it is fixed in 1.5 or it still repros in 1.5? From the earlier comments, it appears to be a dup of the in-app toolbar, but those should be fixed (betwwen 1.5 and VS 17.9).

@JochemPalmsens
Copy link

JochemPalmsens commented Mar 5, 2024

@bpulliam sorry for the confusion. I just wanted to inform the OP that a new version was out.

Now I took the responsibility to test this. No it's not fixed. The in-app toolbar bug was also a bug in 1.4. This is a bug in 1.5

I have made a small test project with identical code (as described in the opening post) and 3 versions of winappsdk: 1.4.240211001, 1.5.240205001-preview1 and 1.5.240227000
With both 1.5 versions the dragged icon "locks up" as soon as I drag it out of the window:
image

So the bug is still in the release of 1.5.

(Disclaimer: I do not take ownership of the code from the OP: I don't know if they are doing something "wrong" that by coincidence worked in 1.4).

@stevenbrix
Copy link
Contributor Author

@bpulliam this is not a dupe of the in-app toolbar. we just tested and this issue is not fixed in the latest 1.5 even with the in-app toolbar disabled

@alcail
Copy link

alcail commented Apr 18, 2024

Our team seems to hit this issue too. Our app is on version 1.5.240311000.
Some examples of Drag&Drop use in our case:

  • Not working anymore when dragging from our app to Desktop, Outlook, or File Explorer
  • Still working when dragging from our app to Teams chat, OneNote Online page, or Clipchamp

@codendone codendone added team-CompInput Issue for IXP (Composition, Input) team Regression and removed team-Markup Issue for the Markup team labels May 2, 2024
@llongley llongley added this to the WinAppSDK 1.6 milestone May 24, 2024
@llongley llongley added the closed-Fixed Described behavior has been fixed. label May 24, 2024
@codendone
Copy link
Contributor

The fix is now also in Version 1.5.4 (1.5.240607001).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-DragAndDrop bug Something isn't working closed-Fixed Described behavior has been fixed. Regression team-CompInput Issue for IXP (Composition, Input) team
Projects
None yet
Development

No branches or pull requests

7 participants