fix: nav_context_menu must produce one submenu per nav item
The segmented_button widget asserts that context_menu children count matches model length. The yoda fork was building a single flat menu for the clicked item instead of iterating over all nav_model items like upstream, causing an assertion panic on right-click in the sidebar (trash, folders, etc.). Align with upstream: iterate self.nav_model.iter() and use menu::nav_context() instead of menu::items().
This commit is contained in:
parent
542657b557
commit
30e562c8c2
1 changed files with 87 additions and 82 deletions
|
|
@ -2833,7 +2833,7 @@ impl Application for App {
|
|||
fn nav_context_menu(
|
||||
&self,
|
||||
) -> Option<Vec<widget::menu::Tree<cosmic::Action<Self::Message>>>> {
|
||||
let entity = self.nav_bar_context_id;
|
||||
let items = self.nav_model.iter().map(|entity| {
|
||||
let favorite_index_opt = self.nav_model.data::<FavoriteIndex>(entity);
|
||||
let location_opt = self.nav_model.data::<Location>(entity);
|
||||
|
||||
|
|
@ -2919,8 +2919,13 @@ impl Application for App {
|
|||
NavMenuAction::EmptyTrash,
|
||||
));
|
||||
}
|
||||
items
|
||||
});
|
||||
|
||||
Some(cosmic::widget::menu::items(&HashMap::new(), items))
|
||||
Some(cosmic::widget::menu::nav_context(
|
||||
&HashMap::new(),
|
||||
items.collect(),
|
||||
))
|
||||
}
|
||||
|
||||
fn nav_model(&self) -> Option<&segmented_button::SingleSelectModel> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue