Skip to content

Commit fa40e69

Browse files
authored
Interaction::Hovered fix (#21375)
# Objective The `Interaction` component only gets set to `None` and `Pressed` atm. fixes #21374 ## Solution The second while loop through `hovered_nodes` needs to reuse the iterator from the first while loop. Instead it creates a new iterator and sets `Interaction::None` for all hovered nodes, not just the ones that are blocked.
1 parent 8a164b7 commit fa40e69

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

crates/bevy_ui/src/focus.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ pub fn ui_focus_system(
302302

303303
// set Pressed or Hovered on top nodes. as soon as a node with a `Block` focus policy is detected,
304304
// the iteration will stop on it because it "captures" the interaction.
305-
let mut iter = node_query.iter_many_mut(hovered_nodes.iter());
305+
let mut hovered_nodes = hovered_nodes.iter();
306+
let mut iter = node_query.iter_many_mut(hovered_nodes.by_ref());
306307
while let Some(node) = iter.fetch_next() {
307308
if let Some(mut interaction) = node.interaction {
308309
if mouse_clicked {
@@ -329,7 +330,7 @@ pub fn ui_focus_system(
329330
}
330331
// reset `Interaction` for the remaining lower nodes to `None`. those are the nodes that remain in
331332
// `moused_over_nodes` after the previous loop is exited.
332-
let mut iter = node_query.iter_many_mut(hovered_nodes.iter());
333+
let mut iter = node_query.iter_many_mut(hovered_nodes);
333334
while let Some(node) = iter.fetch_next() {
334335
if let Some(mut interaction) = node.interaction {
335336
// don't reset pressed nodes because they're handled separately

0 commit comments

Comments
 (0)