Skip to content

[pull] main from tldraw:main#445

Merged
pull[bot] merged 1 commit intocode:mainfrom
tldraw:main
Mar 13, 2026
Merged

[pull] main from tldraw:main#445
pull[bot] merged 1 commit intocode:mainfrom
tldraw:main

Conversation

@pull
Copy link
Copy Markdown

@pull pull Bot commented Mar 13, 2026

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

In order to show developers how to intercept tldraw's Tab-based shape
navigation and redirect focus to custom UI, this PR adds a new example
demonstrating a focus trap pattern with a contextual toolbar.

The example registers a capture-phase `keydown` listener in `onMount`
that intercepts Tab before tldraw's own handler, redirecting focus
between the canvas and a contextual toolbar. It also handles Shift+Tab
cycling and Escape to return focus to the canvas.

Relates to #2549

### Change type

- [x] `other`

### Test plan

1. Open the "Escape shape focus trap" example
2. Click on the geo shape to select it
3. Press Tab — focus should move to the first toolbar button (Duplicate)
4. Press Tab again — focus moves to the Delete button
5. Press Tab again — focus returns to the canvas
6. Press Shift+Tab to cycle backwards through toolbar buttons
7. Press Escape while focused in the toolbar — focus returns to the
canvas

### Release notes

- Add example showing how to intercept Tab navigation to focus a custom
contextual toolbar

### Code changes

| Section       | LOC change |
| ------------- | ---------- |
| Documentation | +220 / -0  |

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk: adds a self-contained UI example and docs demonstrating
keyboard focus handling without changing core library behavior.
> 
> **Overview**
> Adds a new `escape-shape-focus-trap` UI example that renders a
contextual toolbar for selected shapes and uses a capture-phase
`keydown` listener to override tldraw’s Tab-based shape navigation.
> 
> The example demonstrates trapping `Tab`/`Shift+Tab` within toolbar
buttons, restoring focus back to the canvas at the ends of the cycle,
and handling `Escape` to return focus, with accompanying README
guidance.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
af19804. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@pull pull Bot locked and limited conversation to collaborators Mar 13, 2026
@pull pull Bot added the ⤵️ pull label Mar 13, 2026
@pull pull Bot merged commit 4ce7243 into code:main Mar 13, 2026
4 of 8 checks passed
@pull pull Bot had a problem deploying to deploy-production March 13, 2026 21:13 Failure
@pull pull Bot had a problem deploying to deploy-staging March 13, 2026 21:13 Error
@pull pull Bot had a problem deploying to vsce publish March 13, 2026 21:13 Failure
@pull pull Bot had a problem deploying to deploy-staging March 13, 2026 21:13 Failure
@pull pull Bot had a problem deploying to deploy-staging March 14, 2026 00:28 Failure
@pull pull Bot temporarily deployed to e2e-dotcom March 14, 2026 02:36 Inactive
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant