Skip to content

[Problem/Bug]: AllowHostInputProcessing and Scroll Selection Events not scrolling past Window Bounds #5375

@RickStrahl

Description

@RickStrahl

What happened?

I'm running into some issues where events get eaten by AllowInputHostProcessing with some events that I can't seem to intercept not making it back into WebView.

As part of my initialization I can run either with the option on or off. The behavior I see differs in regards to how the window and controls within (an edit control) scroll. Specifically what doesn't work is selection scroll which is when you select text and scroll beyond the bottom of the control which normally keeps scrolling.

With AllowInputHostProcessing on, you can't scroll past the bottom of the page - the selection won't scroll and extend past the bottom of the input control (or document if selecting in a top level document).

With AllowInputHostProcessing set to true:

Image

I'm selecting and attempting to drag past the bottom of the viewport, but selection stops at the bottom.

With AllowInputHostProcessing set to false:

Image

I'm selecting past the bottom of the viewport, and the selection extends down as the browser/editor scrolls.

In this case it's an editor representation, but the same behavior is exhibited with the top level document in the browser (see repro scenario below).

How I'm running

For the editor I enable AllowInputHostProcessing by default in order to handle menu accelerators properly. For the most part this works great - there are a few other edge events like tab/esc keys that I've worked around but mostly this works as expected.

To enable/disable I have a generic routine that I can pass the setting as an option during config:

if (allowHostInputProcessing)
{
    var opts = Environment.CreateCoreWebView2ControllerOptions();
    opts.AllowHostInputProcessing = true;                    
    await webBrowser.EnsureCoreWebView2Async(environment, opts);
}
else
    await webBrowser.EnsureCoreWebView2Async(environment);

This is the only change between what you see in the first and second screen caps.

For the key events I've been able to intercept keyboard handlers at the form level and send keys back into the browser, but in this case some of the events related to mouse and scroll events appear to not forward back into the browser short circuiting the selection scroll behavior.

To be clear - normal scroll works correctly. It's specifically selection scroll that's not working as expected.

I've tried to intercept various mouse and drag events in WPF and short circuit them but they never seem to get fired by the drag selection operation. There are so many possible events involved I'm not sure that this would work anyway.

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

140.0.3485.81

SDK Version

1.0.3405.78

Framework

WPF

Operating System

Windows 11

OS Version

10.0.26100

Repro steps

  • Clone https://github.com/RickStrahl/Westwind.WebView.
  • Run WpfSample Project
  • Run the Basic Interop Sample
  • Select the bottom WebView Pane
  • Make the view so some content is below the viewport window
  • Go to top and shift-select text with the mouse
  • Keep selecting and move to the bottom to drag select

What you'll see is that you can select to the bottom but the selection will not allow dragging past the bottom.

  • Stop running.
  • Change the code in BasicInterop.Xaml.cs
  • AllowInputHostProcessing default to false
  • Re-run w/ same steps as above

Now when when you shift select you'll see two differences:

  • Selection is MUCH faster
  • Selection will scroll past the bottom of the viewport

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions