menu: Fix sub menu gap. (#1006)

<img width="334" alt="image"
src="https://github.com/user-attachments/assets/1f1a9515-f52d-4171-9e53-56d18f923be0"
/>
This commit is contained in:
Jason Lee 2025-06-24 19:33:22 +08:00 committed by GitHub
parent 9aa593ce0b
commit dfa3c9a29e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -813,10 +813,10 @@ impl PopupMenu {
) )
.when(hovered, |this| { .when(hovered, |this| {
let (anchor, left) = let (anchor, left) =
if window.bounds().size.width - bounds.origin.x < max_width { if max_width + bounds.origin.x > window.bounds().size.width {
(Corner::TopRight, -px(12.)) (Corner::TopRight, -px(14.))
} else { } else {
(Corner::TopLeft, bounds.size.width + px(4.)) (Corner::TopLeft, bounds.size.width)
}; };
let is_bottom_pos = let is_bottom_pos =
@ -829,7 +829,7 @@ impl PopupMenu {
div() div()
.occlude() .occlude()
.when(is_bottom_pos, |this| this.bottom_0()) .when(is_bottom_pos, |this| this.bottom_0())
.when(!is_bottom_pos, |this| this.top(-px(4.))) .when(!is_bottom_pos, |this| this.top_neg_1())
.left(left) .left(left)
.child(menu.clone()), .child(menu.clone()),
) )