Fix stored-value widget ID collisions

This commit is contained in:
Dandaedre 2026-11-03 16:32:34 +01:00
parent c5b3bc6638
commit 4747e5165d
1 changed files with 42 additions and 1 deletions

View File

@ -971,7 +971,11 @@ impl App {
let formatted = cell_text(cell);
ui.add(egui::Label::new(&formatted).wrap());
if formatted != cell.text {
ui.collapsing("Stored value", |ui| { ui.monospace(&cell.text); });
egui::CollapsingHeader::new("Stored value")
.id_salt((row, c))
.show(ui, |ui| {
ui.monospace(&cell.text);
});
}
}
if let Some(formula) = &cell.formula {
@ -2200,6 +2204,43 @@ mod tests {
);
}
#[test]
fn stored_value_headers_have_unique_ids() {
let mut app = sample();
for (column, raw) in [(0, "0.375"), (1, "0.003472222222222222")] {
app.tables[0].rows[1][column] = crate::model::Cell {
text: raw.into(),
numeric: true,
time_style: true,
..Default::default()
};
}
app.analysis = None;
app.selected_row = Some(2);
app.row_details = true;
let ctx = egui::Context::default();
configure_style(&ctx);
let size = [860.0, 900.0];
render(&mut app, &ctx, size, vec![]);
let labels = render(&mut app, &ctx, size, vec![]);
let stored: Vec<_> = labels
.iter()
.filter(|(text, _)| text == "Stored value")
.collect();
assert_eq!(stored.len(), 2);
let second = stored[1].1.center();
render(
&mut app,
&ctx,
size,
vec![egui::Event::PointerMoved(second)],
);
let labels = render(&mut app, &ctx, size, vec![]);
assert!(!labels.iter().any(|(text, _)| {
text.contains("use of widget ID") || text.contains("Widget is above this text")
}));
}
#[test]
fn bulk_ignore_includes_missing_titles_but_skips_timing_errors_and_decisions() {
let mut app = sample();