Skip to content

Commit 545a97d

Browse files
authored
Fix: Clears directional navigation map between rebuilds (#22124)
# Objective - Closes #21949 ## Solution - Implements the solution as suggested by 21949. The Directional Navigation Map does not prune any old edges that may be connected to removed Nodes, so we clear the map between rebuilds of the map. (If the more preferable solution figures out what nodes were removed and then calls `map.remove_multiple` instead, you can feel free to reject this) ## Testing - Did you test these changes? If so, how? I did not test this change, but the reporter of the issue did (via backport to an older version of Bevy). However, the fix is straightforward and explains itself. If you would like an automated test somehow, some pointers to tests that do similar would be welcome.
1 parent 2765ba8 commit 545a97d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

crates/bevy_input_focus/src/directional_navigation.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,8 @@ fn auto_rebuild_ui_navigation_graph(
773773
})
774774
.collect();
775775

776+
// clear the old nav map between rebuilds to ensure any removed entities' edges are pruned
777+
directional_nav_map.clear();
776778
auto_generate_navigation_edges(&mut directional_nav_map, &nodes, &config);
777779
}
778780

0 commit comments

Comments
 (0)