From e9650d17a40169968315b14f78c07faf2fa53ebe Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 18 Nov 2026 16:09:36 -0800 Subject: [PATCH] Image Trace: switching tools during a divider drag puts the view back Switching away from the Selection tool while dragging the Split view's divider left the drag's interaction open with its preview in the document. The Selection tool now cancels the drag on deactivate, as Escape does, as it already did for the corner, pie, side and blend widgets. --- crates/tools/src/select.rs | 1 + crates/tools/src/trace_split.rs | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/crates/tools/src/select.rs b/crates/tools/src/select.rs index 851e28664a..34b08bd2c0 100644 --- a/crates/tools/src/select.rs +++ b/crates/tools/src/select.rs @@ -915,6 +915,7 @@ impl Tool for SelectionTool { State::Corner(c) if c.adjusting() => vec![Action::Cancel], State::Pie(d) if d.adjusting() => vec![Action::Cancel], State::Sides(d) => d.cancel(), + State::TraceSplit(d) => d.cancel(), State::BlendWidget(_) | State::Corner(_) | State::Pie(_) => vec![], other => { self.state = other; diff --git a/crates/tools/src/trace_split.rs b/crates/tools/src/trace_split.rs index 1cb7018c99..6ec3509789 100644 --- a/crates/tools/src/trace_split.rs +++ b/crates/tools/src/trace_split.rs @@ -234,4 +234,27 @@ mod tests { assert!(matches!(drag.cancel()[..], [Action::Cancel])); } } + + /// Switching away from the Selection tool during a divider drag cancels it, as Escape does: + /// the view goes back. After a press that has not moved there is nothing to put back. + #[test] + fn a_tool_switch_cancels_a_divider_drag() { + use crate::{PointerEvent, PointerKind, Tool}; + let paint = paint(); + let mut selection = Selection::default(); + let (doc, id) = traced(Affine::translate((10.0, 20.0)), "split", 0.5); + selection.set([id]); + let c = cx(&doc, &selection, &paint); + let mut t = crate::select::SelectionTool::default(); + assert!(t.pointer(&c, &PointerEvent::new(PointerKind::Down, 60.0, 40.0)).is_empty()); + let a = t.pointer(&c, &PointerEvent::new(PointerKind::Drag, 85.0, 40.0)); + assert!(matches!(a.first(), Some(Action::Begin(_))), "{a:?}"); + assert_eq!(t.deactivate(&c), vec![Action::Cancel]); + assert!(!t.busy() && !t.transforming()); + assert!(t.pointer(&c, &PointerEvent::new(PointerKind::Up, 85.0, 40.0)).is_empty()); + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 60.0, 40.0)); + assert!(t.busy()); + assert!(t.deactivate(&c).is_empty()); + assert!(!t.busy()); + } }