fix(menu): give each popup instance its own id

This commit is contained in:
Hojjat 2026-09-08 15:06:11 -06:00 • committed by Michael Murphy
parent 6081a48cd3
commit 9f634b0ec2
3 changed files with 12 additions and 18 deletions

View file

@ -115,16 +115,12 @@ impl<Message: Clone + 'static> ContextMenu<'_, Message> {
shell.publish(self.on_surface_action.as_ref().unwrap()(destroy_popup(id)));
state.view_cursor = view_cursor;
(
id,
layout.children().map(|lo| lo.bounds()).collect::<Vec<_>>(),
)
} else {
(
window::Id::unique(),
layout.children().map(|lo| lo.bounds()).collect(),
)
}
// A fresh id per popup, so the old popup's Done cannot be mistaken for the new one's
(
window::Id::unique(),
layout.children().map(|lo| lo.bounds()).collect::<Vec<_>>(),
)
});
let Some(context_menu) = self.context_menu.as_mut() else {
return;

View file

@ -389,13 +389,12 @@ where
state.active_root.clear();
shell.publish(surface_action(destroy_popup(id)));
state.view_cursor = view_cursor;
(id, layout.children().map(|lo| lo.bounds()).collect())
} else {
(
window::Id::unique(),
layout.children().map(|lo| lo.bounds()).collect(),
)
}
// A fresh id per popup, so the old popup's Done cannot be mistaken for the new one's
(
window::Id::unique(),
layout.children().map(|lo| lo.bounds()).collect(),
)
});
let mut popup_menu: Menu<'static, _> = Menu {

View file

@ -938,10 +938,9 @@ where
state.active_root.clear();
shell.publish(surface_action(destroy_popup(id)));
state.view_cursor = view_cursor;
id
} else {
window::Id::unique()
}
// A fresh id per popup, so the old popup's Done cannot be mistaken for the new one's
window::Id::unique()
});
let Some(entity) = state.show_context else {
return;