fix(event): handle AnyLabel listeners in `emit_to` (#11581)

closes #11561
This commit is contained in:
Mikkel Tønder 2024-11-04 13:31:18 +01:00 committed by GitHub
parent c33bbf4574
commit f8994b214e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
"tauri": "patch:bug"
---
Fix listeners created with `EventTarget::AnyLabel` never receiving events.

View File

@ -597,7 +597,31 @@ impl<R: Runtime> AppManager<R> {
} => self.emit_filter(event, payload, |t| match t {
EventTarget::Window { label }
| EventTarget::Webview { label }
| EventTarget::WebviewWindow { label } => label == &target_label,
| EventTarget::WebviewWindow { label }
| EventTarget::AnyLabel { label } => label == &target_label,
_ => false,
}),
EventTarget::Window {
label: target_label,
} => self.emit_filter(event, payload, |t| match t {
EventTarget::AnyLabel { label } | EventTarget::Window { label } => label == &target_label,
_ => false,
}),
EventTarget::Webview {
label: target_label,
} => self.emit_filter(event, payload, |t| match t {
EventTarget::AnyLabel { label } | EventTarget::Webview { label } => label == &target_label,
_ => false,
}),
EventTarget::WebviewWindow {
label: target_label,
} => self.emit_filter(event, payload, |t| match t {
EventTarget::AnyLabel { label } | EventTarget::WebviewWindow { label } => {
label == &target_label
}
_ => false,
}),