Skip to content

fix: draw mode can now be exited without drawing#120

Merged
boennemann merged 1 commit intomainfrom
ui-glitches
Mar 25, 2026
Merged

fix: draw mode can now be exited without drawing#120
boennemann merged 1 commit intomainfrom
ui-glitches

Conversation

@boennemann
Copy link
Copy Markdown
Contributor

Summary

  • Root cause: entering draw mode called toggleToolbar() which internally calls setMode(null), resetting activeMode before the async setupGlobalDrawCanvas() runs. All teardown paths became no-ops.
  • Closes radial toolbar via direct dispatch instead of toggleToolbar()
  • Replaces broken deps().setMode(null) indirection in discard path with inline cleanup (same pattern the save path uses successfully)
  • Inlines draw teardown in setMode() for reliable mode switching

Test plan

  • Enter draw mode → click Done without drawing → exits
  • Draw a stroke → ESC → confirm bar → click Discard → exits
  • Draw a stroke → Done → saves (regression check)
  • Enter draw mode → Cmd+Shift+F → switches to select-element mode
  • Enter draw mode → Cmd+Shift+S → switches to screenshot mode
  • 16 new regression tests covering all exit paths

🤖 Generated with Claude Code

Root cause: entering draw mode called toggleToolbar() to close the radial
menu, but toggleToolbar() internally calls setMode(null) — immediately
resetting activeMode to null before the async setupGlobalDrawCanvas()
could run. The draw canvas existed in the DOM but the store thought we
weren't in draw mode, so all teardown paths were no-ops.

Fixes:
- Close radial toolbar via direct dispatch instead of toggleToolbar()
- Replace deps().setMode(null) indirection in onDone(false) with inline
  cleanup matching the proven save path pattern
- Inline draw teardown in setMode() for mode-switch reliability
- Wrap cleanup() calls in try/catch for resilience

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@boennemann boennemann merged commit 59e9ed8 into main Mar 25, 2026
16 checks passed
@boennemann boennemann deleted the ui-glitches branch March 25, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant