Skip to content

Commit f778a61

Browse files
fix: correct position when document scrollbar is on left side with fixed strategy
1 parent ed7afa5 commit f778a61

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

packages/dom/src/utils/get_rect_relative_to_offset_parent.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ pub fn get_rect_relative_to_offset_parent(
3232
let mut scroll = NodeScroll::new(0.0);
3333
let mut offsets = Coords::new(0.0);
3434

35+
// If the <body> scrollbar appears on the left (e.g. RTL systems).
36+
// Use Firefox with layout.scrollbar.side = 3 in about:config to test this.
37+
let set_left_rtl_scrollbar_offset = |offsets: &mut Coords| {
38+
offsets.x = get_window_scroll_bar_x(&document_element, None);
39+
};
40+
3541
#[allow(clippy::nonminimal_bool)]
3642
if is_offset_parent_an_element || (!is_offset_parent_an_element && !is_fixed) {
3743
if get_node_name((&offset_parent).into()) != "body"
@@ -52,13 +58,15 @@ pub fn get_rect_relative_to_offset_parent(
5258
offsets.y = offset_rect.y + offset_parent.client_top() as f64;
5359
}
5460
DomElementOrWindow::Window(_) => {
55-
// If the <body> scrollbar appears on the left (e.g. RTL systems).
56-
// Use Firefox with layout.scrollbar.side = 3 in about:config to test this.
57-
offsets.x = get_window_scroll_bar_x(&document_element, None);
61+
set_left_rtl_scrollbar_offset(&mut offsets);
5862
}
5963
}
6064
}
6165

66+
if is_fixed && !is_offset_parent_an_element {
67+
set_left_rtl_scrollbar_offset(&mut offsets);
68+
}
69+
6270
let html_offset = if !is_offset_parent_an_element && !is_fixed {
6371
get_html_offset(&document_element, &scroll, None)
6472
} else {

0 commit comments

Comments
 (0)