Clear pending keystrokes when an action is dispatched

This commit is contained in:
Nathan Sobo 2023-12-20 19:52:08 -07:00
parent 4f6bef5b63
commit 5747c9b7a1
3 changed files with 17 additions and 5 deletions

View file

@ -572,6 +572,17 @@ impl<'a> WindowContext<'a> {
});
}
pub(crate) fn clear_pending_keystrokes(&mut self) {
self.window
.rendered_frame
.dispatch_tree
.clear_pending_keystrokes();
self.window
.next_frame
.dispatch_tree
.clear_pending_keystrokes();
}
/// Schedules the given function to be run at the end of the current effect cycle, allowing entities
/// that are currently on the stack to be returned to the app.
pub fn defer(&mut self, f: impl FnOnce(&mut WindowContext) + 'static) {
@ -1626,6 +1637,10 @@ impl<'a> WindowContext<'a> {
}
}
if !actions.is_empty() {
self.clear_pending_keystrokes();
}
for action in actions {
self.dispatch_action_on_node(node_id, action.boxed_clone());
if !self.propagate_event {