fix(editor): allow TldrawEditor to work without TldrawUiContextProvider#7053
Merged
mimecuvalo merged 3 commits intomainfrom Nov 6, 2025
Merged
fix(editor): allow TldrawEditor to work without TldrawUiContextProvider#7053mimecuvalo merged 3 commits intomainfrom
mimecuvalo merged 3 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
4 Skipped Deployments
|
MitjaBezensek
approved these changes
Nov 6, 2025
1 task
TldrawUiContextProvider
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 -->
2 tasks
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 -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
if you wanted to use TldrawEditor by itself, you weren't able to use some tldraw shapes b/c they relied on
TldrawUiContextProviderbeing present which could bloat your bundle size unnecessarily if you didn't need all that extra stuffH/T to @derekcicerone for flagging this one — thanks!
Change type
bugfiximprovementfeatureapiotherTest plan
Release notes
TldrawUiContextProviderNote
Make note shape RTL logic resilient to missing UI translation context so TldrawEditor works standalone, add CSS.supports polyfill, and expand shape rendering tests.
NoteShapeUtilto use optionalTranslationsContext(fallback to LTR) for RTL/tab navigation, avoiding hard dependency onTldrawUiContextProvider.TranslationsContextfromui/hooks/useTranslation/useTranslation(marked internal).TldrawEditor.test.tsxto render and validate all core shapes (no error boundaries), usedefaultShapeUtils, and test selection/tool switching with rich text helpers.CSS.supportspolyfill ininternal/config/vitest/setup.tsfor color space-related tests.Written by Cursor Bugbot for commit da964bd. This will update automatically on new commits. Configure here.