Skip to content

Commit

Permalink
Fix lost scroll offset on tab switch (#722)
Browse files Browse the repository at this point in the history
* Update view.rs

* fix fmt

This fixes the issue by not computing layout on hidden items
---------

Co-authored-by: charlescgs <[email protected]>
  • Loading branch information
jrmoulton and charlescgs authored Jan 3, 2025
1 parent dbed4ef commit ac031e6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,14 @@ impl View for Box<dyn View> {
pub fn default_compute_layout(id: ViewId, cx: &mut ComputeLayoutCx) -> Option<Rect> {
let mut layout_rect: Option<Rect> = None;
for child in id.children() {
let child_layout = cx.compute_view_layout(child);
if let Some(child_layout) = child_layout {
if let Some(rect) = layout_rect {
layout_rect = Some(rect.union(child_layout));
} else {
layout_rect = Some(child_layout);
if !child.style_has_hidden() {
let child_layout = cx.compute_view_layout(child);
if let Some(child_layout) = child_layout {
if let Some(rect) = layout_rect {
layout_rect = Some(rect.union(child_layout));
} else {
layout_rect = Some(child_layout);
}
}
}
}
Expand Down

0 comments on commit ac031e6

Please sign in to comment.