From ecf8d16f3edbcd99dcdaa0516c570c1afe5baae6 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Fri, 20 Dec 2024 14:01:31 -0600 Subject: [PATCH] Fix event closure invoked recursively (#3405) --- packages/web/src/dom.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/web/src/dom.rs b/packages/web/src/dom.rs index b46770844..bc9b91788 100644 --- a/packages/web/src/dom.rs +++ b/packages/web/src/dom.rs @@ -80,7 +80,10 @@ impl WebsysDom { let interpreter = Interpreter::default(); - let handler: Closure = Closure::wrap(Box::new({ + // The closure type we pass to the dom may be invoked recursively if one event triggers another. For example, + // one event could focus another element which triggers the focus event of the new element like inhttps://github.com/DioxusLabs/dioxus/issues/2882. + // The Closure type can invoked recursively, but Closure cannot + let handler: Closure = Closure::wrap(Box::new({ let runtime = runtime.clone(); move |web_sys_event: &web_sys::Event| { let name = web_sys_event.type_();