Repository navigation
enhance: Add an option to control browser-level autofill behavior on Windows #1649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
34345aa
2eadced
b069e6c
ebfc81f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'wry': 'patch:enhance' | ||
| --- | ||
|
|
||
| Add an option to control browser-level autofill behavior on Windows. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -792,6 +792,25 @@ pub struct WebViewAttributes<'a> { | |
|
|
||
| /// Whether JavaScript should be disabled. | ||
| pub javascript_disabled: bool, | ||
|
|
||
| /// Controls the WebView's browser-level general autofill behavior. | ||
| /// | ||
| /// **This option does not disable password or credit card autofill.** | ||
| /// | ||
| /// When enabled, the WebView may automatically populate form fields using | ||
| /// previously stored data such as addresses or contact information. | ||
| /// | ||
| /// If not specified, this is `true` by default. | ||
| /// Setting this to `false` preserves the default platform behavior. | ||
| /// | ||
| /// ## Platform-specific | ||
| /// | ||
| /// - **Windows**: Supported. On Windows, WebView2's autofill feature (called | ||
| /// "Suggestions") may not honor `autocomplete="off"` attributes on input | ||
| /// elements in some cases. When this option is `false`, that autofill | ||
|
Comment on lines
+807
to
+809
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oof i had a comment pending here for ages but didn't see that. Do you have some source or references for that issue? I don't think i heard about this before.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, thanks for checking! The behavior I mentioned is documented in the Wry issue #1535, which explains that WebView2’s “Suggestions” (autofill) may ignore In practice, i’ve observed this in clash-verge-rev/clash-verge-rev#5944 , where using The Wry issue references the official WebView2 setting
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I can't really reproduce that though
That sounds correct no? You asked the browser to trigger autocomplete with new-password I think maybe we could remove this part from the docs, I don't mind adding this in the wry webview settings though
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I was able to successfully reproduce this issue in the clash-verge-rev/clash-ver#5944. However, when I created a brand new Tauri project to build a minimal reproduction case, I failed to reproduce it, and the root cause remains unclear.
This is not the intended behavior. According to the MDN documentation for the
I will fully follow the decision on whether to remove this part from the docs or add it to the wry webview settings.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was previously handling an issue with
Though this is not directly related to the issue, just curious.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Exactly. Currently, Tauri and Wry do not expose However, as we discussed, these frontend hacks are unreliable because WebView2/Chromium often overrides them. This is precisely why I initiated this PR: to provide a robust, native way to disable autofill at the WebView level during construction, rather than relying on inconsistent HTML attributes. |
||
| /// behavior will be disabled. | ||
| /// - **macOS / Linux / Android / iOS**: Unsupported and ignored. | ||
| pub general_autofill_enabled: bool, | ||
| } | ||
|
|
||
| impl Default for WebViewAttributes<'_> { | ||
|
|
@@ -834,6 +853,7 @@ impl Default for WebViewAttributes<'_> { | |
| }), | ||
| background_throttling: None, | ||
| javascript_disabled: false, | ||
| general_autofill_enabled: true, | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -1405,6 +1425,28 @@ impl<'a> WebViewBuilder<'a> { | |
| self | ||
| } | ||
|
|
||
| /// Controls the WebView's browser-level general autofill behavior. | ||
| /// | ||
| /// **This option does not disable password or credit card autofill.** | ||
| /// | ||
| /// When enabled, the WebView may automatically populate form fields using | ||
|
aoxiangtianyu-go marked this conversation as resolved.
Resolved
|
||
| /// previously stored data such as addresses or contact information. | ||
| /// | ||
| /// If not specified, this is `true` by default. | ||
| /// Setting this to `false` preserves the default platform behavior. | ||
|
aoxiangtianyu-go marked this conversation as resolved.
Resolved
|
||
| /// | ||
| /// ## Platform-specific | ||
| /// | ||
| /// - **Windows**: Supported. On Windows, WebView2's autofill feature (called | ||
| /// "Suggestions") may not honor `autocomplete="off"` attributes on input | ||
| /// elements in some cases. When this option is `false`, that autofill | ||
| /// behavior will be disabled. | ||
| /// - **macOS / Linux / Android / iOS**: Unsupported and ignored. | ||
| pub fn with_general_autofill_enabled(mut self, enabled: bool) -> Self { | ||
| self.attrs.general_autofill_enabled = enabled; | ||
| self | ||
| } | ||
|
|
||
| /// Consume the builder and create the [`WebView`] from a type that implements [`HasWindowHandle`]. | ||
| /// | ||
| /// # Platform-specific: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.