diff --git a/crates/bevy_ui/src/accessibility.rs b/crates/bevy_ui/src/accessibility.rs index 42b2137e9c..f54d2efff3 100644 --- a/crates/bevy_ui/src/accessibility.rs +++ b/crates/bevy_ui/src/accessibility.rs @@ -8,9 +8,10 @@ use bevy_a11y::{ }; use bevy_app::{App, Plugin, Update}; use bevy_ecs::{ - prelude::Entity, - query::{Changed, Or, Without}, + prelude::{DetectChanges, Entity}, + query::{Changed, Without}, system::{Commands, Query}, + world::Ref, }; use bevy_hierarchy::Children; use bevy_render::prelude::Camera; @@ -34,23 +35,22 @@ fn calc_name(texts: &Query<&Text>, children: &Children) -> Option> { fn calc_bounds( camera: Query<(&Camera, &GlobalTransform)>, - mut nodes: Query< - (&mut AccessibilityNode, &Node, &GlobalTransform), - Or<(Changed, Changed)>, - >, + mut nodes: Query<(&mut AccessibilityNode, Ref, Ref)>, ) { if let Ok((camera, camera_transform)) = camera.get_single() { for (mut accessible, node, transform) in &mut nodes { - if let Some(translation) = - camera.world_to_viewport(camera_transform, transform.translation()) - { - let bounds = Rect::new( - translation.x.into(), - translation.y.into(), - (translation.x + node.calculated_size.x).into(), - (translation.y + node.calculated_size.y).into(), - ); - accessible.set_bounds(bounds); + if node.is_changed() || transform.is_changed() { + if let Some(translation) = + camera.world_to_viewport(camera_transform, transform.translation()) + { + let bounds = Rect::new( + translation.x.into(), + translation.y.into(), + (translation.x + node.calculated_size.x).into(), + (translation.y + node.calculated_size.y).into(), + ); + accessible.set_bounds(bounds); + } } } } diff --git a/crates/bevy_ui/src/layout/mod.rs b/crates/bevy_ui/src/layout/mod.rs index b1556515eb..14da00866d 100644 --- a/crates/bevy_ui/src/layout/mod.rs +++ b/crates/bevy_ui/src/layout/mod.rs @@ -6,7 +6,7 @@ use bevy_ecs::{ change_detection::DetectChanges, entity::Entity, event::EventReader, - query::{Changed, With, Without}, + query::{With, Without}, removal_detection::RemovedComponents, system::{Query, Res, ResMut, Resource}, world::Ref, @@ -222,7 +222,7 @@ pub fn ui_layout_system( root_node_query: Query, Without)>, style_query: Query<(Entity, Ref