dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.26k stars 9.96k forks source link

Blazor webassembly: @onwheel:preventDefault has no effect #24932

Open sergey-su opened 4 years ago

sergey-su commented 4 years ago

Describe the bug

Adding @onwheel:preventDefault attribute does not prevent the default scrolling behavior.

To Reproduce

In Counter demo project, on Index page

<h1 @onwheel:preventDefault>Hello, world!</h1>

The page still bumps up or down when I perform two fingers scroll gesture which indicates that the event was not suppressed.

Further technical details

Counter demo project on mac from command line. Versions:

    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.0-preview.7.20365.19" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.0-preview.7.20365.19" PrivateAssets="all" />
    <PackageReference Include="System.Net.Http.Json" Version="5.0.0-preview.7.20364.11" />

Workarouond

interop.js:

window.myUtils = {
    addDefaultPreventingHandler: function (element, eventName) {
        element.addEventListener(eventName, e => e.preventDefault(), { passive: false });
    }
};

the page:

protected override async Task OnAfterRenderAsync(bool firstRender)
{
    if (firstRender)
        await jsRuntime.InvokeVoidAsync("myUtils.addDefaultPreventingHandler", myElementReference, "wheel");
}

Possibly blazor does not set the passive option correctly when it adds its event listener. It should disable the scroll optimization by setting passive: false when @on<EVENT>:preventDefault is present for a scrolling event in the razor markup.

ghost commented 4 years ago

Thanks for contacting us. We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We will evaluate the request when we are planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

ghost commented 3 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost commented 2 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost commented 9 months ago

To learn more about what this message means, what to expect next, and how this issue will be handled you can read our Triage Process document. We're moving this issue to the .NET 9 Planning milestone for future evaluation / consideration. Because it's not immediately obvious what is causing this behavior, we would like to keep this around to collect more feedback, which can later help us determine how to handle this. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact work.