Open VegasVault opened 3 years ago
Hi @VegasVault , can you share more info about how you Create a draggable element and a dropzone
? Did you write code yourself, is it a 3rd party component, or something else?
Code was just a test snippet I wrote using standard blazor with no 3rd party libraries. Works in chrome but once published as a MAUI app it would only fire the drag start. Simple code example below.
<ul>
<li draggable="true" id="source" @ondragstart="OnDragStart" style="background-color:blue;color:white;width:50px;height:50px;">drag me</li>
</ul>
<div dropzone="move" id="target" @ondrop="OnDrop" ondragover="event.preventDefault();" style="background-color:green;color:white;width:200px;height:200px;">
and drop me here
</div>
<div>@DragState</div>
@code {
public string DragState = "No drag";
public void OnDragStart(DragEventArgs dragEventArgs)
{
DragState = "drag started";
}
public void OnDrop(DragEventArgs dragEventArgs)
{
DragState = "item dropped";
}
}
Thanks @VegasVault , I was able to repro this exactly in Android, and also saw some other odd behavior in Windows/WinUI/WebView2 where the drag does start, but it's extremely slow (unusable), and the drop doesn't seem to work. We'll have to dig a bit deeper into this.
Interestingly, it works fine in WPF and WinForms with WebView2. I can drag and drop and everything works as expected.
OnDrag is not triggering at all. Also when Im trying to drag draggable element, leave the area of the maui app (latest preview, Windows 11), then move cursor over Microsoft Edge I can see the element Im dragging, but I can't see it in the app. It follows the cursor inside Microsoft Edge and then the app just crashes. When it crashes element is where the cursor was during crash. It stays there like on the picture but now not only in the Microsoft Edge but everywhere like it's burned into the screen.
It looks like some serious bug.
@Swordancer thank you for the extra info.
We've moved this issue to the Future milestone. This means that it is not going to be worked on for the coming release. We will reassess the issue following the current release and consider this item at that time.
Issue persists with DropZones, at least in net6.0 Windows version of Blazor App.
Microsoft Visual Studio Community 2022 Version 17.4.0 Preview 1.0 VisualStudio.17.Preview/17.4.0-pre.1.0+32804.182 Microsoft .NET Framework Version 4.8.04161
Is there any known work around?
Hi, this appears to be an issue with WebView2 running on WinUI, so I logged a new bug for that here: https://github.com/MicrosoftEdge/WebView2Feedback/issues/2805. Please up-vote to help raise awareness of the issue. I'm closing this issue here as there is no further action required in the .NET MAUI repo. Thanks!
@Eilon has the original issue of Blazor for android drag and drop been fixed in .net 7?
Oops, I forgot that this issue is specifically about Android. The other issue I linked is Windows-specific. We'll keep this one open for investigation. Sorry about the confusion!
This bug affects any app that needs drag and drop capabilities, it is really important for many apps, any plans on when is going to be fixed?
I just ran into this on .NET 7 too.. drag and drop being broken with no workaround is a pretty major issue.
@Tailslide There's a workaround but it requires a huge effort, as you could use MAUI (not Blazor) drag and drop capabilities. With MAUI Blazor hybrid you can mix and match these two technologies, but your app architecture gets much more complicated. https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/gestures/drag-and-drop?view=net-maui-7.0 Hope they can fix this bug asap!
There's a workaround
I don’t think this works in most cases since my existing project uses blazor controls.. I would love to be wrong about that though. I wound up switching to browser based blazor.
In theory drag & drop should work within the BlazorWebView, but there appear to be some bugs related to this. You could certainly try to use .NET MAUI's native drag & drop, but that would be separate code that is MAUI-specific. If you have existing Blazor components that already do drag & drop, you should be able to use that code as-is.
@Eilon Thanks for the tip I wasn't aware of BlazorWebView.. it reminds me of back in the day loading a browser inside an activeX control. I think the best solution for me is to carry on with blazor and hope for a bugfix later on down the road. Looks like maybe in a pinch I could publish it as a windows service:
Hi everyone, I've been taking another look at this issue and so far I have not been able to find any drag & drop web/HTML/JS sample that works on Android at all.
So.... I'm wondering how well drag & drop works in Android Chrome and/or Android WebView in general. Without a repro that satisfies that case, I don't think there's any further work to track in this item (that is, there might be an issue, but it's more likely an issue in Android WebView, Chrome, or Chromium).
Does anyone have an example that does work in Android Chrome or a regular Android WebView, yet doesn't work in a .NET MAUI BlazorWebView on Android? If so, can you post the exact HTML you're using, and ideally have a demo of it running live (perhaps on JSFiddle, or using GitHub pages, just like the MDN example I linked to)?
Thanks, Eilon
Hi @VegasVault. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
Thanks @VegasVault , I was able to repro this exactly in Android, and also saw some other odd behavior in Windows/WinUI/WebView2 where the drag does start, but it's extremely slow (unusable), and the drop doesn't seem to work. We'll have to dig a bit deeper into this.
Seems this was reproduced a year and a half ago from the snippet that I posted 🤔
MS can close the issue but this seems this will keep resurfacing as drag and drop seems pretty essential for mobile.
@VegasVault I totally agree, such a big bug makes this development framework (Maui + Blazor) not reliable for now.
Regarding this:
Thanks @VegasVault , I was able to repro this exactly in Android, and also saw some other odd behavior in Windows/WinUI/WebView2 where the drag does start, but it's extremely slow (unusable), and the drop doesn't seem to work. We'll have to dig a bit deeper into this.
Seems this was reproduced a year and a half ago from the snippet that I posted 🤔
MS can close the issue but this seems this will keep resurfacing as drag and drop seems pretty essential for mobile.
And this:
@VegasVault I totally agree, such a big bug makes this development framework (Maui + Blazor) not reliable for now.
My concern is that there is either an issue with the Android WebView itself, in which case we need to send a bug report to Google/Chromium, or there is some issue with how people are using the JavaScript/DOM/browser drag/drop APIs. In my experience, I couldn't get any reliable drag/drop behavior anywhere in any Android web/HTML/browser experience. If that's the case, there's nothing we can do in .NET MAUI or Blazor if the underlying issue is in a different component.
Hi @VegasVault. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
@Eilon
https://codepen.io/miclgael/pen/JqWJma
Here is a working example that functioned fine on my android using the brave browser(chromium based).
Thank you @VegasVault I'll take another look.
Hi, after small research I've been able to find out the following things:
Vanilla drag-and-drop implementation does not work in Android as stated here: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event
Some drag-and-drop implementations work, some others don't (I haven't research why)
This library works in Android Webview native and I have been able to successfully implemented for Maui/Blazor for Android (in Windows still does not work): https://github.com/SortableJS/Sortable
Example of that library in web that also works when implemented within an Android Webview: https://www.cssscript.com/demo/drag-drop-sortablejs/
Here's another library that I have been able to successfully implement in Maui/Blazor for Android: https://github.com/ThibaultJanBeyer/DragSelect
Example: https://www.cssscript.com/demo/draggable-selectable/
When the implementation works in Android Webview (or any chromium based browser) it works for Maui/Blazor
@ismasanchez thank you for all this info! Perhaps at a minimum we could write up some of this as guidance for Blazor Hybrid developers. I'll have to look into it some more, but I feel like we'll end up determining that there's nothing we can do in Blazor Hybrid itself and it's just an Android WebView limitation.
@Eilon None of those implementations mentioned before work on Windows, any thoughts on that?
@Eilon None of those implementations mentioned before work on Windows, any thoughts on that?
Hmm I just tried the ones you linked running Edge on Win11 and they worked. Do they specifically not work in WeView in .NET MAUI? If so I'll have to take a look.
FWIW I used the dropzone component from mudblazor and the same page works in blazor and doesn't work in MAUI. (Windows not android).
@Eilon None of those implementations mentioned before work on Windows, any thoughts on that?
Hmm I just tried the ones you linked running Edge on Win11 and they worked. Do they specifically not work in WeView in .NET MAUI? If so I'll have to take a look.
Correct, it doesn't work when implemented within a BlazorWebView component in .NET MAUI and run on Windows.
Has there been any further development on this issue?
I just ran into this problem today, been attempting to write a drag and drop function into a custom library for about 4 hours now, thinking I was just being stupid every time it didn't work. Do we know when this is likely to be fixed?
FWIW I used the dropzone component from mudblazor and the same page works in blazor and doesn't work in MAUI. (Windows not android).
@Tailslide - on Windows this doesn't work due to this issue with WebView2: https://github.com/MicrosoftEdge/WebView2Feedback/issues/2805 (please up-vote if you agree!)
And on Android Chrome web browser it doesn't seem to work at all (just the regular browser, not in a .NET MAUI app or using Blazor).
I'm not saying this is the fault of MudBlazor, but given that the sample doesn't work outside of .NET MAUI on those platforms, I wouldn't expect it to work inside .NET MAUI / Blazor Hybrid either.
I've spent several more hours on this and I'm afraid I haven't been able to find an example that satisfies this condition:
I'm thankful for the code samples that were posted here but I was unable to find one that satisfies those conditions.
To make further progress on this, I think the best repro would be one where there is a Blazor Web app (either Blazor Server or Blazor WebAssembly) that uses Drag/Drop that works in a regular browser on a given platform, but the same Blazor component doesn't work in a .NET MAUI Blazor Hybrid app on particular platforms, especially Android. We know there's an issue with WebView2 on Windows (https://github.com/MicrosoftEdge/WebView2Feedback/issues/2805 - please up-vote if you agree!), but I don't have enough information (or knowledge) to investigate any potential Android issue.
I'm not saying this is the fault of MudBlazor, but given that the sample doesn't work outside of .NET MAUI on those platforms, I wouldn't expect it to work inside .NET MAUI / Blazor Hybrid either.
I'd suggest re-opening issue #9983 to avoid confusion.. just because webview2 is causing things to fail doesn't mean it's no longer an issue and people searching for information will be able to figure out what's going on. Either way thanks for the info. I'm no longer using MAUI but best of luck.
I'd suggest re-opening issue #9983 to avoid confusion.. just because webview2 is causing things to fail doesn't mean it's no longer an issue and people searching for information will be able to figure out what's going on. Either way thanks for the info. I'm no longer using MAUI but best of luck.
People can still find that issue, but it's closed because there's no action to be taken in this repo.
Has there been any further development on this issue?
I need to use drag & drop but can't find any solution
@goensin if you need implementation for Android, you can use one of the libraries mentioned previously, but for Windows none of those work. It's sad, because they aren't able to fix whatever bug is inside Window's Webview on .NET/MAUI with Blazor, all being Microsoft products.
@goensin if you need implementation for Android, you can use one of the libraries mentioned previously, but for Windows none of those work. It's sad, because they aren't able to fix whatever bug is inside Window's Webview on .NET/MAUI with Blazor, all being Microsoft products.
Thank you. It seems I have to replace it. 😭
Interestingly, it works fine in WPF and WinForms with WebView2. I can drag and drop and everything works as expected.
@danroth27 Any insights or downside to using this approach until the issue is fixed?
@danroth27 Any insights or downside to using this approach until the issue is fixed?
@QadiymStewart Sure, Blazor Hybrid is supported with WPF and WinForms. You won't get the cross-platform benefits of .NET MAUI, but if you only need to target Windows, then that's a valid approach. We're talking with the WebView2 folks to try to get https://github.com/MicrosoftEdge/WebView2Feedback/issues/2805 fixed.
Please fix this bug soon. Drag and drop is a core functionality for many applications.
Unfortunately, it still does not work for Windows. The start drag even fires, but then all the UI just freezes with no proper indication that the element is being dragged. Releasing the mouse sometimes unfreezes the UI, but sometimes the whole application just crashes. I am using the default MAUI Blazor template with Net 7.
I also think drag and drop is an absolute must. For all platforms! If that doesn't work, Maui Blazor might be cancelled.
Hive any alternative methods?
Still no news?
We are using Mudblazor Drop Zone and facing the same issue on UWP and Android. Tried creating a custom component and couldn't find a way to make it work either. As others pointed out, this functionality is quite important.
Description
When using MAUI with blazor template add a draggable component. Long press will recognize you are attempting to drag but no functionality is present.
Steps to Reproduce
Expected Behavior
It should allow you to drag an element as it does on a browser.
Actual Behavior
OnDragStart fires but no actual functionality is present.
Basic Information
Version with issue: Preview 6 and 7
Last known good version: None
IDE: Visual Studio 2022 Preview 3.1
Platform Target Frameworks:
Nuget Packages:
Affected Devices: Physical and emulated
Screenshots
Reproduction Link
Workaround
Depends on