diff --git a/crates/ui-egui/src/panels/swatches/dnd.rs b/crates/ui-egui/src/panels/swatches/dnd.rs index 05ff15e78d..36c8be4e5f 100644 --- a/crates/ui-egui/src/panels/swatches/dnd.rs +++ b/crates/ui-egui/src/panels/swatches/dnd.rs @@ -277,7 +277,12 @@ pub(super) fn apply_drop(app: &mut VectorcraftApp, drop: Drop) { ("swatch.edit", json!({"name": t, "paint": crate::panels::swatch_paint_params(&paint)})) } Drop::New { paint, target, spot, .. } => { - let mut p = crate::panels::swatch_paint_params(&paint); + // A new spot color is made from the color the drag showed, not from its base swatch as it is now. + let source = match paint.color() { + Some(c) if spot && !paint.is_registration() => Paint::solid(c), + _ => paint.clone(), + }; + let mut p = crate::panels::swatch_paint_params(&source); if paint.color().is_some() { if let Some(g) = target.and_then(|t| group_of(d, &t)) { p["group"] = json!(g); diff --git a/crates/ui-egui/src/panels/swatches/tests.rs b/crates/ui-egui/src/panels/swatches/tests.rs index 293bccfaae..f823e1c920 100644 --- a/crates/ui-egui/src/panels/swatches/tests.rs +++ b/crates/ui-egui/src/panels/swatches/tests.rs @@ -1210,6 +1210,22 @@ fn cmd_drops_of_tints_and_with_alt_follow_the_replacement_rule() { assert!(app.session.doc().unwrap().doc.swatch("Orange 40%").is_some_and(|w| w.tint_of().is_some())); } +/// A tint Cmd/Ctrl-dropped becomes a spot color of the color the drag showed, even when its base +/// swatch changes between the drag start and the drop. +#[test] +fn a_cmd_dropped_tint_makes_its_spot_from_the_captured_color() { + let mut app = app(); + let ctx = context(); + app.run("swatch.edit", json!({"name": "Orange", "global": true})).unwrap(); + app.run("swatch.new", json!({"swatch": "Orange", "tint": 40})).unwrap(); + let tint = app.session.doc().unwrap().doc.tint_paint("Orange", 0.4).expect("a tint of Orange"); + let shown = tint.color().expect("a color"); + app.run("swatch.edit", json!({"name": "Orange", "paint": {"color": "#2040c0"}})).unwrap(); + drop_paint_on(&mut app, &ctx, "Red", tint, Modifiers::COMMAND, 1.0); + let newest = newest_swatch(&app); + assert_eq!((newest.paint, newest.spot), (Paint::solid(shown), true), "{}", app.ui.status); +} + /// A Recent Colors chip of the Color panel dragged onto the Swatches panel becomes a swatch; a click /// on it still paints the selected art. #[test]