Skip to content

Commit

Permalink
Merge pull request #271 from iced-rs/menu_fix
Browse files Browse the repository at this point in the history
Menu fix
  • Loading branch information
genusistimelord authored Jul 21, 2024
2 parents 5cb704d + a1a897c commit 8fdab86
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/widgets/menu/menu_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Default for MenuState {
active: None,
slice: MenuSlice {
start_index: 0,
end_index: usize::MAX,
end_index: usize::MAX - 1,
lower_bound_rel: 0.0,
upper_bound_rel: f32::MAX,
},
Expand Down Expand Up @@ -390,10 +390,12 @@ where

Check failure on line 390 in src/widgets/menu/menu_tree.rs

View workflow job for this annotation

GitHub Actions / all

Diff in /home/runner/work/iced_aw/iced_aw/src/widgets/menu/menu_tree.rs
let menu_state = tree.state.downcast_ref::<MenuState>();
let slice = &menu_state.slice;
let max_item_slice = self.items.len()-1.min(slice.end_index);
let max_tree_slice = tree.children.len()-1.min(slice.end_index);

self.items[slice.start_index..=slice.end_index]
self.items[slice.start_index..=max_item_slice]
.iter()
.zip(tree.children[slice.start_index..=slice.end_index].iter()) // [item_tree...]
.zip(tree.children[slice.start_index..=max_tree_slice].iter()) // [item_tree...]
.zip(slice_layout.children()) // [item_layout...]
.map(|((item, tree), layout)| {
item.mouse_interaction(tree, layout, cursor, viewport, renderer)
Expand Down

0 comments on commit 8fdab86

Please sign in to comment.