Skip to content

fix(editor): allow TldrawEditor to work without TldrawUiContextProvider#7053

Merged
mimecuvalo merged 3 commits intomainfrom
mime/i18n-context
Nov 6, 2025
Merged

fix(editor): allow TldrawEditor to work without TldrawUiContextProvider#7053
mimecuvalo merged 3 commits intomainfrom
mime/i18n-context

Conversation

@mimecuvalo
Copy link
Copy Markdown
Member

@mimecuvalo mimecuvalo commented Oct 31, 2025

if you wanted to use TldrawEditor by itself, you weren't able to use some tldraw shapes b/c they relied on TldrawUiContextProvider being present which could bloat your bundle size unnecessarily if you didn't need all that extra stuff

H/T to @derekcicerone for flagging this one — thanks!

Change type

  • bugfix
  • improvement
  • feature
  • api
  • other

Test plan

  • Unit tests
  • End to end tests

Release notes

  • editor: be able to use TldrawEditor without needing TldrawUiContextProvider

Note

Make note shape RTL logic resilient to missing UI translation context so TldrawEditor works standalone, add CSS.supports polyfill, and expand shape rendering tests.

  • Editor / Shapes:
    • Update NoteShapeUtil to use optional TranslationsContext (fallback to LTR) for RTL/tab navigation, avoiding hard dependency on TldrawUiContextProvider.
  • UI / Translations:
    • Export TranslationsContext from ui/hooks/useTranslation/useTranslation (marked internal).
  • Tests:
    • Revamp TldrawEditor.test.tsx to render and validate all core shapes (no error boundaries), use defaultShapeUtils, and test selection/tool switching with rich text helpers.
  • Tooling / Polyfills:
    • Add CSS.supports polyfill in internal/config/vitest/setup.ts for color space-related tests.

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

@huppy-bot huppy-bot bot added the bugfix Bug fix label Oct 31, 2025
@vercel
Copy link
Copy Markdown

vercel bot commented Oct 31, 2025

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

Project Deployment Preview Updated (UTC)
analytics Ready Ready Preview Nov 6, 2025 1:49pm
examples Ready Ready Preview Nov 6, 2025 1:49pm
4 Skipped Deployments
Project Deployment Preview Updated (UTC)
chat-template Ignored Ignored Preview Nov 6, 2025 1:49pm
tldraw-docs Ignored Ignored Preview Nov 6, 2025 1:49pm
tldraw-shader Ignored Ignored Preview Nov 6, 2025 1:49pm
workflow-template Ignored Ignored Preview Nov 6, 2025 1:49pm

@mimecuvalo mimecuvalo enabled auto-merge November 6, 2025 13:46
@mimecuvalo mimecuvalo added this pull request to the merge queue Nov 6, 2025
Merged via the queue into main with commit 7308566 Nov 6, 2025
20 checks passed
@mimecuvalo mimecuvalo deleted the mime/i18n-context branch November 6, 2025 14:02
@steveruizok steveruizok changed the title editor: be able to use TldrawEditor without needing TldrawUiContextProvider fix(editor): allow TldrawEditor to work without TldrawUiContextProvider Jan 2, 2026
@steveruizok steveruizok added the sdk Affects the tldraw sdk label Jan 2, 2026
NathanFlurry pushed a commit to rivet-dev/tldraw that referenced this pull request Jan 18, 2026
…rovider` (tldraw#7053)

if you wanted to use TldrawEditor by itself, you weren't able to use
some tldraw shapes b/c they relied on `TldrawUiContextProvider` being
present which could bloat your bundle size unnecessarily if you didn't
need all that extra stuff

H/T to @derekcicerone for flagging this one — thanks!

### Change type

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

### Test plan

- [x] Unit tests
- [ ] End to end tests

### Release notes

- editor: be able to use TldrawEditor without needing
`TldrawUiContextProvider`

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Make note shape RTL logic resilient to missing UI translation context
so TldrawEditor works standalone, add CSS.supports polyfill, and expand
shape rendering tests.
> 
> - **Editor / Shapes**:
> - Update `NoteShapeUtil` to use optional `TranslationsContext`
(fallback to LTR) for RTL/tab navigation, avoiding hard dependency on
`TldrawUiContextProvider`.
> - **UI / Translations**:
> - Export `TranslationsContext` from
`ui/hooks/useTranslation/useTranslation` (marked internal).
> - **Tests**:
> - Revamp `TldrawEditor.test.tsx` to render and validate all core
shapes (no error boundaries), use `defaultShapeUtils`, and test
selection/tool switching with rich text helpers.
> - **Tooling / Polyfills**:
> - Add `CSS.supports` polyfill in `internal/config/vitest/setup.ts` for
color space-related tests.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
da964bd. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
github-merge-queue bot pushed a commit that referenced this pull request Feb 25, 2026
…rovider (#8011)

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

- [x] `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

- [x] Unit tests

### Release notes

- Fix `TldrawSelectionForeground` crashing when used without
`TldrawUiContextProvider`

<!-- CURSOR_SUMMARY -->
---

> [!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.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
95d5ef8. 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 sdk Affects the tldraw sdk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants