Skip to content

fix(tldraw): allow TldrawSelectionForeground without TldrawUiContextProvider#8011

Merged
mimecuvalo merged 1 commit intomainfrom
mime/fix-selection-ui-context-6236
Feb 25, 2026
Merged

fix(tldraw): allow TldrawSelectionForeground without TldrawUiContextProvider#8011
mimecuvalo merged 1 commit intomainfrom
mime/fix-selection-ui-context-6236

Conversation

@mimecuvalo
Copy link
Copy Markdown
Member

@mimecuvalo mimecuvalo commented Feb 18, 2026

In order to allow SDK users to use TldrawSelectionForeground with TldrawEditor directly (without wrapping in TldrawUiContextProvider), this PR makes useTranslation() gracefully fall back to default English translations when TranslationsContext is not available.

Closes #6236

PR #7053 partially addressed this for NoteShapeUtil but missed TldrawSelectionForeground and its child components (RotateCornerHandle, MobileRotateHandle, TldrawCropHandles), which all call useTranslation(). Rather than patching each component individually, this fixes useTranslation() itself so all current and future consumers are covered.

Change type

  • bugfix

Test plan

  1. Use TldrawEditor with components={{ SelectionForeground: TldrawSelectionForeground }} but without TldrawUiContextProvider
  2. Create and select a shape
  3. Verify the selection foreground renders correctly with resize/rotate handles
  • Unit tests

Release notes

  • Fix TldrawSelectionForeground crashing when used without TldrawUiContextProvider

Note

Low Risk
Small, localized change to a hook to avoid throwing when context is missing, plus a targeted regression test; minimal behavioral impact beyond preventing crashes.

Overview
Fixes a crash when rendering TldrawSelectionForeground (and other UI pieces calling useTranslation) without TldrawUiContextProvider by making useTranslation() fall back to DEFAULT_TRANSLATION when TranslationsContext is absent.

Adds a unit test that mounts TldrawEditor with SelectionForeground: TldrawSelectionForeground and asserts selecting a shape renders the selection foreground without triggering the error boundary.

Written by Cursor Bugbot for commit 95d5ef8. This will update automatically on new commits. Configure here.

…rovider

Make useTranslation() gracefully fall back to default English translations
when TranslationsContext is not available, instead of throwing. This allows
TldrawSelectionForeground (and its child components) to be used with
TldrawEditor directly, without requiring TldrawUiContextProvider.

Closes #6236
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
examples Ready Ready Preview Feb 18, 2026 4:53pm
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
analytics Ignored Ignored Feb 18, 2026 4:53pm
chat-template Ignored Ignored Feb 18, 2026 4:53pm
tldraw-docs Ignored Ignored Feb 18, 2026 4:53pm
tldraw-shader Ignored Ignored Feb 18, 2026 4:53pm
workflow-template Ignored Ignored Feb 18, 2026 4:53pm

Request Review

@mimecuvalo mimecuvalo added this pull request to the merge queue Feb 25, 2026
Merged via the queue into main with commit 85626c5 Feb 25, 2026
24 checks passed
@mimecuvalo mimecuvalo deleted the mime/fix-selection-ui-context-6236 branch February 25, 2026 12:37
steveruizok added a commit that referenced this pull request Feb 27, 2026
Add 12 new entries from PRs merged since v4.4.0:
- Featured: click-through on transparent image pixels (#7942)
- API: enum-to-const-object refactor (#8084)
- Improvements: SVG sanitizer (#7896), save-on-blur (#8037)
- Bug fixes: cross-origin download (#8090), zero-size draw (#8067),
  rich text toolbar cleanup (#8050), zoom threshold (#8040),
  selection foreground fallback (#8011), sticky note SVG shadow (#7934),
  arrow frame clamping (#7932), zero pressure draw (#5693)
github-merge-queue bot pushed a commit that referenced this pull request Mar 5, 2026
followup to #8011
tiny nit feedback from @MitjaBezensek 

### Change type

- [ ] `bugfix`
- [ ] `improvement`
- [ ] `feature`
- [ ] `api`
- [x] `other`

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk: adds a `console.warn` when `useTranslation` cannot find
translation messages, which may increase log noise but does not change
translation lookup behavior.
> 
> **Overview**
> `useTranslation` now emits a `console.warn` when no translation
messages are present and it falls back to `DEFAULT_TRANSLATION`, making
missing/incorrect translation provider setup more visible during
development.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
cd95cda. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot use TldrawSelectionForeground without TldrawUiContextProvider

2 participants