Description
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.
Metadata
Metadata
Assignees
Labels
Work that is critical for the release, but we could probably ship withoutThis issue impacts only small number of customersIncludes: Blazor, Razor ComponentsThis issue describes a behavior which is not expected - a bug.Any feature that affects the component model for Blazor (Parameters, Rendering, Lifecycle, etc)This label is used by an internal tool