Repository navigation
Artboard tool: Delete and Backspace delete the active artboard - #650
Conversation
The Artboard tool handled Delete/Backspace in Tool::key, but never claimed the keys through Tool::claims_key. The UI only routes Delete/Backspace to a tool that claims them, so the keypress went to the Clear shortcut instead and the artboard stayed. The existing tests called the tool directly and missed it. The tool now claims Delete/Backspace while no drag is in progress and more than one artboard exists. With only one artboard left, the keys stay with the shortcut. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged. Thank you, @mateususa! 🎉 This is a great first PR. You found the real cause (the Artboard tool handled Delete but never claimed it, so the shortcut router gave the key to Clear) instead of patching around it. Having I checked it through the real keyboard path in the running app: with the Artboard tool, clicking the second artboard and pressing Delete removes it, and with one artboard left, Delete and Backspace leave it alone. Full If you'd like to chat with us and other contributors, come join https://discord.gg/artcraft |
What and why
With the Artboard tool (Shift+O), clicking an artboard and pressing Delete or Backspace does nothing. The artboard can only be removed with the trash button in the Artboards panel.
Cause:
ArtboardTool::keyhandles Delete/Backspace, but the tool never overridesTool::claims_key.ui-egui/src/shortcuts.rsonly hands Delete/Backspace to a tool that claims them, so the keypress goes to the Clear shortcut instead. Clear deletes selected objects and leaves the artboard alone. Tools such as Gradient, Puppet Warp and Slice already claim their keys this way; the Artboard tool was missing it. The existing tests callArtboardTool::key/Session::tool_keydirectly, which bypasses the routing, so they didn't catch it.Fix:
ArtboardTool::claims_keyclaims Delete/Backspace while no drag is in progress and the document has more than one artboard.key()checks the same condition, so the two can't drift apart. With a single artboard (which can't be deleted), the keys stay with the shortcut, as before.How it was tested
crates/engine/src/tests_xform.rs(artboard_tool_moves_with_art_creates_and_deletes) now assertstool_claims_key(Delete)before deleting, and asserts that the last artboard doesn't claim it. This test fails onmain(assertion failed: s.tool_claims_key(ToolKey::Delete, …)) and passes with this change.crates/tools/src/xform/artboard.rs(move_resize_create_delete) asserts that the tool claims both Delete and Backspace.cargo test -p vectorcraft-tools artboard(12 passed) andcargo test -p vectorcraft-engine artboard_tool(4 passed).cargo fmt --checkandcargo clippy -p vectorcraft-tools --all-targets -D warningsare clean.Checklist
cargo xtask cipasses. I ran the touched crates' tests, fmt and clippy, but not the fullxtask ci.unwrap(),expect()or similar outside tests, and no unchecked indexing.🤖 Generated with Claude Code