diff --git a/crates/ui-egui/src/ribbon.rs b/crates/ui-egui/src/ribbon.rs index e8291accd..388584073 100644 --- a/crates/ui-egui/src/ribbon.rs +++ b/crates/ui-egui/src/ribbon.rs @@ -1426,7 +1426,13 @@ fn insert(app: &mut SheetApp, ui: &mut Ui) { let __k = big_button(ui, Icon::Chart, "Recommended\nCharts", "Recommended Charts", false); control_keytip(app, ui, &__k, "insert.recommendedCharts"); if __k.clicked() { - act(app, "insert.recommendedCharts", json!({})); + match app.run("insert.recommendedCharts", json!({})) { + // The new chart is selected, as after inserting any other object (see insert.chart + // in dialogs.rs) — otherwise the prior cell/range selection is left in place, and + // Del right after inserting deletes the source data instead of the chart. + Ok(r) => app.selected_chart = r.get("chart").and_then(serde_json::Value::as_u64).and_then(|id| u32::try_from(id).ok()), + Err(e) => app.message = Some(("GridCraft".into(), crate::clean_error(&e))), + } } ui.vertical(|ui| { ui.horizontal(|ui| {