fix: select a newly inserted chart from Recommended Charts

Resubmit of the selection half of #224 against current main, as
requested — the Delete-key half was a duplicate of #219 and is
already merged.

Insert > Recommended Charts left the prior cell/range selection in
place instead of selecting the new chart, unlike every other object
insertion path (see insert.chart in dialogs.rs, which already selects
the chart it creates). With the selection left on the source data,
pressing Del right after inserting deleted that data and left an
empty chart behind (#214).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Dejan Port
2026-10-12 01:31:29 +02:00
co-authored by Claude Sonnet 5
parent 3926d21aa9
commit faba681c99
+7 -1
View File
@@ -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| {