diff --git a/.changes/resources-close-fallback.md b/.changes/resources-close-fallback.md new file mode 100644 index 000000000000..2a7c15eec33c --- /dev/null +++ b/.changes/resources-close-fallback.md @@ -0,0 +1,5 @@ +--- +"tauri": patch:enhance +--- + +Fallback to the Window and AppHandle resource table when closing a resource by ID. diff --git a/crates/tauri/src/resources/plugin.rs b/crates/tauri/src/resources/plugin.rs index 7786fe74e38a..cf82886120a4 100644 --- a/crates/tauri/src/resources/plugin.rs +++ b/crates/tauri/src/resources/plugin.rs @@ -12,7 +12,14 @@ use super::ResourceId; #[command(root = "crate")] fn close(webview: Webview, rid: ResourceId) -> crate::Result<()> { - webview.resources_table().close(rid) + let mut result = webview.resources_table().close(rid); + if result.is_err() { + result = webview.window().resources_table().close(rid); + if result.is_err() { + result = webview.app_handle().resources_table().close(rid); + } + } + result } pub(crate) fn init() -> TauriPlugin {