diff --git a/crates/ui-egui/src/panels/swatches/actions.rs b/crates/ui-egui/src/panels/swatches/actions.rs index c1fd461d09..5c3fe41597 100644 --- a/crates/ui-egui/src/panels/swatches/actions.rs +++ b/crates/ui-egui/src/panels/swatches/actions.rs @@ -111,7 +111,8 @@ pub(super) const DRAG_DOC: &str = "swatch-drag-doc"; /// drag, and for a drag started in another document. fn dragged_deletable(app: &VectorcraftApp, ctx: &egui::Context) -> Vec { let Some(st) = app.session.active() else { return vec![] }; - deletable(&dragged_rows(app, ctx)).into_iter().filter(|n| st.doc.swatch_name_taken(n)).collect() + let d = &st.doc; + dragged_rows(app, ctx).into_iter().filter(|n| d.swatch_name_taken(n) && d.swatch(n).is_none_or(|w| !w.is_reserved())).collect() } /// The names of the swatches or color groups of the active document being dragged from the list, diff --git a/crates/ui-egui/src/panels/swatches/tests.rs b/crates/ui-egui/src/panels/swatches/tests.rs index f664b8b8c1..c8e9755cd6 100644 --- a/crates/ui-egui/src/panels/swatches/tests.rs +++ b/crates/ui-egui/src/panels/swatches/tests.rs @@ -695,6 +695,14 @@ fn swatches_dropped_on_delete_swatch_are_deleted_after_asking() { assert_eq!(doc(&app), kept, "{name}"); } assert_eq!(undo_steps(&app), undo + 2); + // A swatch of the user's whose name starts with a bracket is an ordinary swatch. + app.run("swatch.new", json!({"name": "[Blue]", "color": "#0000ff"})).unwrap(); + let undo = undo_steps(&app); + assert_eq!(drag_to_trash(&mut app, &ctx, "[Blue]", Modifiers::NONE, 7.0), (true, true)); + assert_eq!(dialog_message(&app).as_deref(), Some("Delete “[Blue]”?")); + crate::dialogs::confirm(&mut app).unwrap(); + assert!(doc(&app).swatch("[Blue]").is_none(), "OK deletes it"); + assert_eq!(undo_steps(&app), undo + 1); } /// Delete Swatch takes only swatches dragged from the active document's list: a paint dragged from