Skip to content

Commit

Permalink
Fix event closure invoked recursively
Browse files Browse the repository at this point in the history
  • Loading branch information
ealmloff committed Dec 19, 2024
1 parent c2952a7 commit 4762fba
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/web/src/dom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ impl WebsysDom {

let interpreter = Interpreter::default();

let handler: Closure<dyn FnMut(&Event)> = 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<dyn Fn(_)> type can invoked recursively, but Closure<dyn FnMut()> cannot
let handler: Closure<dyn Fn(&Event)> = Closure::wrap(Box::new({
let runtime = runtime.clone();
move |web_sys_event: &web_sys::Event| {
let name = web_sys_event.type_();
Expand Down

0 comments on commit 4762fba

Please sign in to comment.