From c9acba21faf95a1fc9bd440741264b53f8c8887c Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Sat, 22 Nov 2025 11:18:38 +0000 Subject: [PATCH] Fixed two problems: * The content insets returned by `ComputedNode::content_inset` should include the scroll width. * In `update_clipping_system` the clipping rect calculations are incorrect, `scrollbar_size` should only be added to the `right` and `bottom` if when `visual_area` is set to `ContentBox`. For `BorderBox` and `PaddingBox`, the scrollbars are inside the clipping rect. --- crates/bevy_ui/src/ui_node.rs | 5 ++++- crates/bevy_ui/src/update.rs | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index ac086d02a5556..aeaf8e3b1f380 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -222,7 +222,10 @@ impl ComputedNode { /// Returns the combined inset on each edge including both padding and border thickness in physical pixels. #[inline] pub fn content_inset(&self) -> BorderRect { - self.border + self.padding + let mut content_inset = self.border + self.padding; + content_inset.right += self.scrollbar_size.x; + content_inset.bottom += self.scrollbar_size.y; + content_inset } /// Returns the inverse of the scale factor for this node. diff --git a/crates/bevy_ui/src/update.rs b/crates/bevy_ui/src/update.rs index 77659effabcf1..e038a53b645fe 100644 --- a/crates/bevy_ui/src/update.rs +++ b/crates/bevy_ui/src/update.rs @@ -111,8 +111,8 @@ fn update_clipping( clip_rect.min.x += clip_inset.left; clip_rect.min.y += clip_inset.top; - clip_rect.max.x -= clip_inset.right + computed_node.scrollbar_size.x; - clip_rect.max.y -= clip_inset.bottom + computed_node.scrollbar_size.y; + clip_rect.max.x -= clip_inset.right; + clip_rect.max.y -= clip_inset.bottom; clip_rect = clip_rect .inflate(node.overflow_clip_margin.margin.max(0.) / computed_node.inverse_scale_factor);