combobox in a menu button isn't functional
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 30.6k
- Forks
- 2.1k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 72
Description
**Describe the bug**
when using a combobox in a menu button it doesn't work :/
also clicking buttons makes the dialog close normally but that's covered in #335
**To Reproduce**
Steps to reproduce the behavior:
compile this with eframe as a dependency (just a quick test thing i made not the use case)
```rust
fn main() -> Result<(), eframe::Error> {
let mut list: Vec = Vec::new();
let mut index = None;
eframe::run_simple_native("combo test", Default::default(), move |ctx, _| {
use eframe::egui;
egui::CentralPanel::default().show(ctx, |ui| {
let mut show_combo = |ui: &mut egui::Ui| {
ui.horizontal(|ui| {
let mut remove_at = None;
egui::ComboBox::from_id_source("select")
.width(125.0)
.selected_text(match index {
// for some reason this is necessary
Some(i) => &list[i] as &str,
None => "none",
})
.show_ui(ui, |ui| {
if ui.selectable_label(index.is_none(), "none").clicked() {
index = None;
}
for (i, pak) in list.iter().enumerate() {
ui.horizontal(|ui| {
if ui.selectable_label(index == Some(i), pak).clicked() {
index = Some(i);
}
if ui.button("x").clicked() {
remove_at = Some(i);
if index == remove_at {
index = None
}
if index.is_some_and(|index| index > i) {
index.as_mut().map(|i| *i -= 1);
}
}
});
}
});
if let Some(i) = remove_at {
list.remove(i);
}
if ui.button("+").clicked() {
list.push("test".to_string())
}
})
};
show_combo(ui);
ui.menu_button("test", show_combo);
});
})
}
```
**Expected behavior**
selecting something in the first combobox works fine while selecting something in the menu button combobox does nothing and the selected is the same
the same for clicking the remove button
**Desktop (please complete the following information):**
- OS: windows
- Version: 10
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided minimal eframe example and compare ComboBox::show_ui when called directly with the same closure passed to Ui::menu_button. Reproduce the Windows behavior, then trace how selection and button clicks are handled inside the menu-button popup. Done means both the combobox selection and remove button work inside the menu, while the existing direct combobox behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100