Skip to content

[Feature]: Provide a public API to programmatically close the default find/search bar in Webview2 #5377

@sbasuli

Description

@sbasuli

Describe the feature/enhancement you need

Product:
Microsoft.Web.WebView2 (WPF/.NET 8)
Description:
When using the default find/search bar in WebView2, there is no supported way to programmatically close or hide the bar.
• The CoreWebView2 API does not expose a method like StopFind or CloseFindBar.
• Sending synthetic ESC key events (via SendInput, SendMessage, or similar Win32 APIs) does not close the find bar, even when the WebView2 control has focus.
• Only a real, physical ESC key press by the user closes the bar.
Expected Behavior:
There should be a public API to programmatically close the default find/search bar, or synthetic input should be processed the same as real user input.

Actual Behavior:
• No API exists to close the find bar.
• Synthetic ESC key events are ignored by the Chromium input pipeline.
• The only workaround is to suppress the default find UI and implement a custom one, which is not always desirable.

Steps to Reproduce:

  1. Open a WebView2 control in a WPF app.
  2. Show the default find/search bar (Ctrl+F).
  3. Attempt to close it programmatically using SendInput or SendMessage with ESC.
  4. Observe that the bar remains open.
    Workarounds Tried:
    • SendInput and SendMessage with ESC key.
    • Focusing the WebView2 control before sending input.
    • Searching for any public API to close the find bar.

The scenario/use case where you would use this feature

There are some use-case in my application where search bar is opened in one page. Then user is navigating to another page where serchbar is not expected to be visible. This is a customer complaint.

How important is this request to you?

----Please select----

Suggested implementation

Request:
Please provide a public API to programmatically close the default find/search bar, or document a supported way to do so.
Environment:
• WebView2 SDK: [your version]
• .NET: 8.0
• OS: [your OS version]
• WPF

What does your app do? Is there a pending deadline for this request?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions