diff --git a/crates/ui-egui/src/dialogs/save_for_web.rs b/crates/ui-egui/src/dialogs/save_for_web.rs index c34e0acccd..e64f66eb4e 100644 --- a/crates/ui-egui/src/dialogs/save_for_web.rs +++ b/crates/ui-egui/src/dialogs/save_for_web.rs @@ -914,11 +914,12 @@ pub(super) fn optimized_result<'a>(d: &'a Dialog, s: Option<&WebSettings>, art: d.fields.get("__optimized").filter(|r| r["art"] == json!(art) && s.is_some_and(|s| r["settings"] == s.to_json())) } -/// The active document, its revision and its selected objects, which an Optimize to File Size result -/// was measured on. The selection decides the slices Save writes with `slices: selected` and the -/// slice Current Slice measures, and a selection made on the canvas leaves the revision as it is. +/// The active document, its revision and its selected objects and slices, which an Optimize to File +/// Size result was measured on. The selection decides the slices Save writes with `slices: selected` +/// and the slice Current Slice measures, and a selection made on the canvas or with the Slice +/// Selection tool leaves the revision as it is. pub(super) fn art_key(app: &VectorcraftApp) -> String { - app.session.active().map_or_else(String::new, |st| format!("{}:{}:{:?}", st.uid, st.revision, st.selection.objects)) + app.session.active().map_or_else(String::new, |st| format!("{}:{}:{:?}:{:?}", st.uid, st.revision, st.selection.objects, st.selection.slices)) } /// `bytes` in K, rounded up to the Desired File Size field's 0.001 K so the size it asks for holds diff --git a/crates/ui-egui/src/dialogs/tests_save_for_web.rs b/crates/ui-egui/src/dialogs/tests_save_for_web.rs index 9514dbd8e0..17c565e454 100644 --- a/crates/ui-egui/src/dialogs/tests_save_for_web.rs +++ b/crates/ui-egui/src/dialogs/tests_save_for_web.rs @@ -783,6 +783,15 @@ fn optimize_to_file_size_takes_the_settings_that_fit() { assert!(!st.selection.objects.is_empty()); st.selection.objects.clear(); assert!(!shown(&app)); + // And a change to the selected slices alone (the Slice Selection tool). + let mut current = found.clone(); + current["art"] = json!(save_for_web::art_key(&app)); + app.ui.dialog.as_mut().unwrap().fields.insert("__optimized".into(), current); + assert!(shown(&app)); + let st = app.session.active_mut().unwrap(); + let any = st.doc.layers[0].id; + st.selection.slices.push(any); + assert!(!shown(&app)); } /// Enter while the Optimize to File Size rows are open runs the search and writes nothing; once the