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
- Create some shapes on the canvas
- Select one or more shapes with the select tool
- Switch to a different tool (e.g., press 'D' for draw tool)
- Open the zoom menu and observe that "Zoom to selection" is still enabled
- Click "Zoom to selection"
- 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
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
Expected behavior
Either:
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:
ZoomToSelectionMenuItemchecks onlyeditor.getSelectedShapeIds().length > 0to determine if enabledonSelecthandler checkscanApplySelectionAction()which requireseditor.isIn('select')AND has selected shapesEnvironment