Save for Web: an Optimize to File Size result stops holding when the selected slices change

This commit is contained in:
dotCooCoo
2026-11-16 23:01:31 -08:00
parent 437b477241
commit 84e9cf26b7
2 changed files with 14 additions and 4 deletions
+5 -4
View File
@@ -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
@@ -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