Improve cross-realm portability of editor animation frames - #55
Draft
hiroshisuga wants to merge 14 commits into
Draft
Improve cross-realm portability of editor animation frames#55hiroshisuga wants to merge 14 commits into
hiroshisuga wants to merge 14 commits into
Conversation
hiroshisuga
marked this pull request as ready for review
August 12, 2026 14:15
hiroshisuga
marked this pull request as draft
August 12, 2026 14:16
ButtonPicker did not work correctly when the tldraw editor was rendered in another window, such as a detached popup. In that case, the pointerdown and pointerup events occurred in the popup window, while the listener was attached to the main window. As a result, handlePointerUp was never called, rPointing.current remained true, and moving the pointer over other buttons in the style panel could unintentionally select them without clicking. This was visible in style controls using ButtonPicker, including color, fill, dash, and size selectors.
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.
What does this PR do?
This PR makes editor-related animation frames use the
windowthat owns the editor container instead of implicitly using the globalwindow. Thus this would make a good workaround to the problem posted here: bigbluebutton/bigbluebutton#25597 on the second part.It adds
editor.getContainerDocument()andeditor.getContainerWindow(), and uses the container window forrequestAnimationFrame()/cancelAnimationFrame()calls in theeditorandtldrawpackages.This improves the portability of this tldraw fork when the editor is rendered in a different browser window, and brings the fork closer to the direction taken by upstream tldraw.
It also prepares the fork for future BigBlueButton use cases where the whiteboard or presentation may be rendered in another window without replacing global browser APIs, for instance, bigbluebutton/bigbluebutton#25461
Relation to upstream
Upstream tldraw has moved in the same general direction by avoiding assumptions about the global browser realm and by introducing broader timer abstractions.
This PR intentionally takes a smaller approach for this older fork; rather than backporting the complete upstream timer infrastructure, editor-level animation frames directly use:
editor.getContainerWindow()This is sufficient for the current cross-window requirements and keeps the change limited to the
editorandtldrawpackages.Generic timer helpers in lower-level packages are left unchanged because they do not have access to an editor container. Extending the change to those packages would require a quite larger backport.
The goal here is to make the minimum practical change needed to improve cross-window portability while keeping the fork stable and easy to maintain.
Compatibility
Normal single-window tldraw behavior is unchanged.
In the usual case, the editor container belongs to the application's current window, so
editor.getContainerWindow()resolves to the samewindowthat was previously used implicitly.The behavior only differs when the editor is actually hosted in another browser window.
TickManager - a relatively large change
TickManager also remembers the
windowused when requesting a frame so that the frame is cancelled through the same window, even if the editor container moves between windows.Change Type
patch— Bug fixminor— New featuremajor— Breaking changedependencies— Changes to package dependencies1documentation— Changes to the documentation only2tests— Changes to any test code only2internal— Any other changes that don't affect the published package2Test Plan
requestAnimationFrame/cancelAnimationFramereplacement is required.Release Notes
Footnotes
publishes a
patchrelease, for devDependencies useinternal↩will not publish a new version ↩ ↩2 ↩3