diff --git a/.changes/fix-window-emit-target.md b/.changes/fix-window-emit-target.md new file mode 100644 index 000000000..005f832ef --- /dev/null +++ b/.changes/fix-window-emit-target.md @@ -0,0 +1,5 @@ +--- +"tauri": patch +--- + +Properly fill the origin window when using `emit_to` and `emit_all` from `Window`. diff --git a/core/tauri/src/window.rs b/core/tauri/src/window.rs index 143ccc110..d7d45c4ed 100644 --- a/core/tauri/src/window.rs +++ b/core/tauri/src/window.rs @@ -520,7 +520,24 @@ impl PartialEq for Window { } } -impl Manager for Window {} +impl Manager for Window { + fn emit_to( + &self, + label: &str, + event: &str, + payload: S, + ) -> crate::Result<()> { + self + .manager() + .emit_filter(event, Some(self.label()), payload, |w| label == w.label()) + } + + fn emit_all(&self, event: &str, payload: S) -> crate::Result<()> { + self + .manager() + .emit_filter(event, Some(self.label()), payload, |_| true) + } +} impl ManagerBase for Window { fn manager(&self) -> &WindowManager { &self.manager @@ -1339,6 +1356,7 @@ impl Window { source_window_label: Option<&str>, payload: S, ) -> crate::Result<()> { + println!("emit internal {:?} {:?}", event, source_window_label); self.eval(&format!( "window['{}']({{event: {}, windowLabel: {}, payload: {}}})", self.manager.event_emit_function_name(),