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| {
let (anchor, left) =
if window.bounds().size.width - bounds.origin.x < max_width {
(Corner::TopRight, -px(12.))
if max_width + bounds.origin.x > window.bounds().size.width {
(Corner::TopRight, -px(14.))
} else {
(Corner::TopLeft, bounds.size.width + px(4.))
(Corner::TopLeft, bounds.size.width)
};
let is_bottom_pos =
@ -829,7 +829,7 @@ impl PopupMenu {
div()
.occlude()
.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)
.child(menu.clone()),
)