Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changes/disable-autofill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'tauri-runtime': 'minor:feat'
'tauri-runtime-wry': 'minor:feat'
'tauri-utils': 'minor:feat'
'tauri': 'minor:feat'
'@tauri-apps/api': 'minor:feat'
---

Add a WebView option to control browser-level general autofill behavior. This option does not disable password or credit card autofill. On Windows (WebView2), setting it to true disables the general autofill "Suggestions" UI, which may appear even when `autocomplete="off"` is specified on input elements. On Linux, macOS, iOS, and Android, this option is currently unsupported and performs no operation.
5 changes: 5 additions & 0 deletions crates/tauri-cli/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,11 @@
"string",
"null"
]
},
"generalAutofillEnabled": {
"description": "Controls the WebView's browser-level general autofill behavior.\n\n **This option does not disable password or credit card autofill.**\n\n When set to `false`, the WebView will not automatically populate\n general form fields using previously stored data such as addresses\n or contact information.\n\n If not specified, this is `true` by default.\n\n ## Platform-specific\n\n - **Windows**: Supported. WebView2's autofill feature (called\n \"Suggestions\") may not honor `autocomplete=\"off\"` on input\n elements in some cases.\n - **Linux / Android / iOS / macOS**: Unsupported and performs no\n operation.",
"default": true,
"type": "boolean"
}
},
"additionalProperties": false
Expand Down
3 changes: 2 additions & 1 deletion crates/tauri-runtime-wry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4760,7 +4760,8 @@ You may have it installed on another user account, but it is not available for t
.with_accept_first_mouse(webview_attributes.accept_first_mouse)
.with_incognito(webview_attributes.incognito)
.with_clipboard(webview_attributes.clipboard)
.with_hotkeys_zoom(webview_attributes.zoom_hotkeys_enabled);
.with_hotkeys_zoom(webview_attributes.zoom_hotkeys_enabled)
.with_general_autofill_enabled(webview_attributes.general_autofill_enabled);

if url != "about:blank" {
webview_builder = webview_builder.with_url(&url);
Expand Down
45 changes: 44 additions & 1 deletion crates/tauri-runtime/src/webview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,24 @@ pub struct WebviewAttributes {
/// see https://docs.rs/objc2-web-kit/latest/objc2_web_kit/struct.WKWebView.html#method.allowsLinkPreview
pub allow_link_preview: bool,
pub scroll_bar_style: ScrollBarStyle,
/// Controls the WebView's browser-level general autofill behavior.
///
/// **This option does not disable password or credit card autofill.**
///
/// When set to `false`, the WebView will not automatically populate
/// general form fields using previously stored data such as addresses
/// or contact information.
///
/// If not specified, this is `true` by default.
///
/// ## Platform-specific
///
/// - **Windows**: Supported. WebView2's autofill feature (called
/// "Suggestions") may not honor `autocomplete="off"` on input
/// elements in some cases.
/// - **Linux / Android / iOS / macOS**: Unsupported and performs no
/// operation.
pub general_autofill_enabled: bool,
/// Allows overriding the keyboard accessory view on iOS.
/// Returning `None` effectively removes the view.
///
Expand Down Expand Up @@ -441,7 +459,8 @@ impl From<&WindowConfig> for WebviewAttributes {
#[cfg(windows)]
ConfigScrollBarStyle::FluentOverlay => ScrollBarStyle::FluentOverlay,
_ => ScrollBarStyle::Default,
});
})
.general_autofill_enabled(config.general_autofill_enabled);

#[cfg(any(not(target_os = "macos"), feature = "macos-private-api"))]
{
Expand Down Expand Up @@ -516,6 +535,7 @@ impl WebviewAttributes {
javascript_disabled: false,
allow_link_preview: true,
scroll_bar_style: ScrollBarStyle::Default,
general_autofill_enabled: true,
#[cfg(target_os = "ios")]
input_accessory_view_builder: None,
#[cfg(windows)]
Expand Down Expand Up @@ -807,6 +827,29 @@ impl WebviewAttributes {
self.scroll_bar_style = style;
self
}

/// Controls the WebView's browser-level general autofill behavior.
///
/// **This option does not disable password or credit card autofill.**
///
/// When set to `false`, the WebView will not automatically populate
/// general form fields using previously stored data such as addresses
/// or contact information.
///
/// By default, this is `true`.
///
/// ## Platform-specific
///
/// - **Windows**: Supported. WebView2's autofill feature (called
/// "Suggestions") may not honor `autocomplete="off"` on input
/// elements in some cases.
/// - **Linux / Android / iOS / macOS**: Unsupported and performs no
/// operation.
#[must_use]
pub fn general_autofill_enabled(mut self, enabled: bool) -> Self {
self.general_autofill_enabled = enabled;
self
}
}

/// IPC handler.
Expand Down
5 changes: 5 additions & 0 deletions crates/tauri-schema-generator/schemas/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,11 @@
"string",
"null"
]
},
"generalAutofillEnabled": {
"description": "Controls the WebView's browser-level general autofill behavior.\n\n **This option does not disable password or credit card autofill.**\n\n When set to `false`, the WebView will not automatically populate\n general form fields using previously stored data such as addresses\n or contact information.\n\n If not specified, this is `true` by default.\n\n ## Platform-specific\n\n - **Windows**: Supported. WebView2's autofill feature (called\n \"Suggestions\") may not honor `autocomplete=\"off\"` on input\n elements in some cases.\n - **Linux / Android / iOS / macOS**: Unsupported and performs no\n operation.",
"default": true,
"type": "boolean"
}
},
"additionalProperties": false
Expand Down
24 changes: 23 additions & 1 deletion crates/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2270,6 +2270,25 @@ pub struct WindowConfig {
/// By default the system uses the foreground scene.
#[serde(default, alias = "requested-by-scene-identifier")]
pub requested_by_scene_identifier: Option<String>,
/// Controls the WebView's browser-level general autofill behavior.
///
/// **This option does not disable password or credit card autofill.**
///
/// When set to `false`, the WebView will not automatically populate
/// general form fields using previously stored data such as addresses
/// or contact information.
///
/// If not specified, this is `true` by default.
///
/// ## Platform-specific
///
/// - **Windows**: Supported. WebView2's autofill feature (called
/// "Suggestions") may not honor `autocomplete="off"` on input
/// elements in some cases.
/// - **Linux / Android / iOS / macOS**: Unsupported and performs no
/// operation.
#[serde(default = "default_true", alias = "general-autofill-enabled")]
pub general_autofill_enabled: bool,
}

impl Default for WindowConfig {
Expand Down Expand Up @@ -2335,6 +2354,7 @@ impl Default for WindowConfig {
activity_name: None,
created_by_activity_name: None,
requested_by_scene_identifier: None,
general_autofill_enabled: true,
}
}
}
Expand Down Expand Up @@ -3872,6 +3892,7 @@ mod build {
let activity_name = opt_lit(self.activity_name.as_ref());
let created_by_activity_name = opt_lit(self.created_by_activity_name.as_ref());
let requested_by_scene_identifier = opt_lit(self.requested_by_scene_identifier.as_ref());
let general_autofill_enabled = self.general_autofill_enabled;

literal_struct!(
tokens,
Expand Down Expand Up @@ -3935,7 +3956,8 @@ mod build {
scroll_bar_style,
activity_name,
created_by_activity_name,
requested_by_scene_identifier
requested_by_scene_identifier,
general_autofill_enabled
);
}
}
Expand Down
23 changes: 23 additions & 0 deletions crates/tauri/src/webview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,29 @@ fn main() {
self
}

/// Controls the WebView's browser-level general autofill behavior.
///
/// **This option does not disable password or credit card autofill.**
///
/// When set to `false`, the WebView will not automatically populate
/// general form fields using previously stored data such as addresses
/// or contact information.
///
/// By default, this is `true`.
///
/// ## Platform-specific
///
/// - **Windows**: Supported. WebView2's autofill feature (called
/// "Suggestions") may not honor `autocomplete="off"` on input
/// elements in some cases.
/// - **Linux / Android / iOS / macOS**: Unsupported and performs no
/// operation.
#[must_use]
pub fn general_autofill_enabled(mut self, enabled: bool) -> Self {
self.webview_attributes = self.webview_attributes.general_autofill_enabled(enabled);
self
}

/// Whether to show a link preview when long pressing on links. Available on macOS and iOS only.
///
/// Default is true.
Expand Down
23 changes: 23 additions & 0 deletions crates/tauri/src/webview/webview_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,29 @@ impl<R: Runtime, M: Manager<R>> WebviewWindowBuilder<'_, R, M> {
self
}

/// Controls the WebView's browser-level general autofill behavior.
///
/// **This option does not disable password or credit card autofill.**
///
/// When set to `false`, the WebView will not automatically populate
/// general form fields using previously stored data such as addresses
/// or contact information.
///
/// By default, this is `true`.
///
/// ## Platform-specific
///
/// - **Windows**: Supported. WebView2's autofill feature (called
/// "Suggestions") may not honor `autocomplete="off"` on input
/// elements in some cases.
/// - **Linux / Android / iOS / macOS**: Unsupported and performs no
/// operation.
#[must_use]
pub fn general_autofill_enabled(mut self, enabled: bool) -> Self {
self.webview_builder = self.webview_builder.general_autofill_enabled(enabled);
self
}

/// Allows overriding the keyboard accessory view on iOS.
/// Returning `None` effectively removes the view.
///
Expand Down
19 changes: 19 additions & 0 deletions packages/api/src/webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,25 @@ interface WebviewOptions {
* - **Linux / Android / iOS / macOS**: Unsupported. Only supports `Default` and performs no operation.
*/
scrollBarStyle?: ScrollBarStyle
/**
* Controls the WebView's browser-level general autofill behavior.
*
* **This option does not disable password or credit card autofill.**
*
* When set to `false`, the WebView will not automatically populate general form
* fields using previously stored data such as addresses or contact information.
*
* If not specified, this is `true` by default.
*
* ## Platform-specific
*
* - **Windows**: Supported. WebView2's autofill feature (called "Suggestions")
* may not honor `autocomplete="off"` on input elements in some cases.
* - **Linux / Android / iOS / macOS**: Unsupported and performs no operation.
*
* @since 2.11.0
*/
generalAutofillEnabled?: boolean
}

export { Webview, getCurrentWebview, getAllWebviews }
Expand Down
Loading