Skip to content

Zoom to selection button non-functional when not in select tool #7810

@max-drake

Description

@max-drake

Description

When a user has shapes selected and then switches to a different tool (e.g., draw, geo, etc.), the "Zoom to selection" button in the zoom menu remains enabled, but clicking it does nothing.

Steps to reproduce

  1. Create some shapes on the canvas
  2. Select one or more shapes with the select tool
  3. Switch to a different tool (e.g., press 'D' for draw tool)
  4. Open the zoom menu and observe that "Zoom to selection" is still enabled
  5. Click "Zoom to selection"
  6. Nothing happens - the camera doesn't zoom to the selection

Expected behavior

Either:

  • The button should be disabled when not in the select tool (consistent with action behavior), OR
  • Clicking the button should work and zoom to the selection regardless of current tool

Actual behavior

The button appears enabled but clicking it has no effect. This creates a confusing UX where the button seems broken.

Root cause

There's a mismatch between the menu item's enabled state and the action's behavior:

  • ZoomToSelectionMenuItem checks only editor.getSelectedShapeIds().length > 0 to determine if enabled
  • The action's onSelect handler checks canApplySelectionAction() which requires editor.isIn('select') AND has selected shapes
  • When not in the select tool, the action silently returns early, doing nothing

Environment

  • tldraw version: main branch
  • Browser: All
  • OS: All

Metadata

Metadata

Assignees

Labels

sdkAffects the tldraw sdk

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions