Skip to content

Commit

Permalink
Add small padding to context
Browse files Browse the repository at this point in the history
  • Loading branch information
casperstorm committed Oct 4, 2024
1 parent b4d382c commit 82e31fc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/widget/context_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,12 @@ where
.as_widget()
.layout(&mut self.state.menu_tree, renderer, &limits);

let viewport = Rectangle::new(Point::ORIGIN, bounds);
// Small padding to ensure that we don't spawn context menu at the very edge of the viewport.
let padding = 5.0;
let viewport = Rectangle::new(
Point::new(Point::ORIGIN.x + padding, Point::ORIGIN.y + padding),
Size::new(bounds.width - 2.0 * padding, bounds.height - 2.0 * padding),
);
let mut bounds = Rectangle::new(self.position, node.size());

if bounds.x < viewport.x {
Expand Down

0 comments on commit 82e31fc

Please sign in to comment.