Trackpad horizontal scroll permanently locks scrolling axis in MAUI WebView
Issue Summary
After performing a horizontal scroll gesture with a trackpad in a Blazor Hybrid MAUI application, the component becomes locked in "horizontal mode" where all subsequent mouse wheel events are incorrectly processed as horizontal scrolls, making vertical scrolling impossible without restarting the application.
Expected Behavior
After horizontal trackpad scrolling, vertical scrolling with mouse wheel should continue to work normally Mouse wheel events should generate DeltaY values for vertical scrolling
Actual Behavior
After horizontal trackpad scrolling, the WebView becomes locked in a horizontal scroll mode Mouse wheel events incorrectly generate DeltaX values instead of DeltaY values Vertical scrolling becomes impossible with the mouse wheel This state persists indefinitely until the application is restarted
Technical Details
The issue appears to be in how the MAUI WebView processes and transforms browser wheel events after horizontal trackpad gestures. The same code works correctly in Blazor Server and WebAssembly applications, suggesting this is specific to the MAUI WebView implementation or Blazor Hybrid event bridging.
Using event debugging, we can observe:
Before horizontal trackpad gesture: WheelEventArgs.DeltaY contains vertical scroll amounts After horizontal trackpad gesture: WheelEventArgs.DeltaY is always 0, and WheelEventArgs.DeltaX contains values even when scrolling vertically with a mouse wheel
Steps To Reproduce
- Create a project with the ".NET MAUI Blazor Hybrid and Web App" template
- Copy the following code in the Home.razor component:
@page "/"
<div style="height: 100%; width: 100%; overflow: auto; outline: none;">
<div style="position: relative; height: 4000px; width: 4000px; background-color: red;"></div>
</div>
- Start the MAUI Project
- Scroll with a two-finger horizontal gesture on a trackpad After that, try to scroll vertically with a mouse wheel - observe that vertical scrolling is no longer possible
Exceptions (if any)
No response
.NET Version
9.0.101
Anything else?
No response
@sigroli thanks for contacting us.
Does this issue reproduce in a regular Maui Webview without Blazor?
Yes, it reproduces in a regular MAUI WebView without Blazor.
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiApp2.MainPage">
<WebView>
<WebView.Source>
<HtmlWebViewSource Html="<HTML><BODY><div style="height: 100%; width: 100%; overflow: auto; outline: none;"> <div style="position: relative; height: 4000px; width: 4000px; background-color: red;"></div> </div></BODY><HTML>" />
</WebView.Source>
</WebView>
</ContentPage>
@sigroli What platform are you running this on? And does this reproduce if you run that page within that webview implementation standalone, without the MAUI tooling?
For example, if you are running this on WinUI, can you build a WinUI 3 app with a WebView2 control and try it there? Likewise with iOS/Catalyst and WKWebView, etc.
@drasticactions I'm running it on Windows 10 22H2 (Build 19045.5371). Yes, it also reproduces in a WinUI 3 app with a WebView2 control. I'm using the Microsoft.Web.WebView2 package.
MainWindow.xaml
<?xml version="1.0" encoding="utf-8"?>
<Window
x:Class="App1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d"
Title="App1">
<Grid>
<controls:WebView2 x:Name="webView" />
</Grid>
</Window>
MainWindow.xaml.cs
using System;
using Microsoft.UI.Xaml;
namespace App1
{
public sealed partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
InitializeWebView();
}
private async void InitializeWebView()
{
await webView.EnsureCoreWebView2Async();
// Same HTML content as in your MAUI app
string htmlContent = @"<HTML><BODY><div style=""height: 100%; width: 100%; overflow: auto; outline: none;"">
<div style=""position: relative; height: 4000px; width: 4000px; background-color: red;""></div>
</div></BODY></HTML>"
;
webView.CoreWebView2.NavigateToString(htmlContent);
}
}
}
I can confirm similar behavior on Windows 11. I am also using Blazor in a MAUI web view.
I am using a mouse with both horizontal and vertical scroll wheels and I get the same behavior. After using the horizontal wheel, the vertical wheel will also scroll in the horizontal direction. The behavior resets when I resize the window, enabling vertical scrolling until I scroll horizontally, then it locks again. This behavior does not occur in a browser, in Chrome and Firefox this behaves as expected.
Difficult for me to share proprietary code, but suffice it to say that my situation is very similar to OP in terms of architecture and implementation.
I also noticed this issue a few weeks ago. I don't know exactly when it started, or if it always existed. However I have never upgraded the libraries.
I confirm the same issue happens in a BlazorWebView in Maui. Furthermore, this is not only an issue when using horizontal scroll gesture, but also when using the horizontal scroll button which some mice have. Several of my colleagues at work are using a Logitech MX Master3, and are experiencing the same problem.
The Javascript "wheel" event shows a positive deltaX value, and a deltaY value of 0. Refreshing the page does not fix the issue. The only solutions are: resizing the window or restarting the application.
OS: WIndows 11 24H2 .NET version: 8
Duplicate of https://github.com/MicrosoftEdge/WebView2Feedback/issues/5114