Merged
Conversation
The output we get from the markdown parser doesn't include <head> or <body> but by emitting documentElement.innerHTML here we'll always wrap the contents in <head></head><body>{...}</body>
This in turn will break our logic to only re-render the sandboxed markdown component if the markup changes.
Replaces manual div ref management with React.createRef for frameContainingDivRef in SandboxedMarkdown. Updates related logic to use the current property and removes the custom ref callback for improved clarity and consistency.
…need for debounce any more
Prevents jumping around
Previously we would render markdown to string, put that in the iframe, then parse that string into a Document, apply a filter on it, stringify it, push to iframe, repeating for each filter. Now instead we can just let the filters loose on the iframe document and only recalculate the height when something has changed inside the iframe DOM.
No need for error handler, it won't cause a crash
tidy-dev
reviewed
Jan 12, 2026
| @@ -0,0 +1,9 @@ | |||
| export function isElement<T extends keyof HTMLElementTagNameMap>( | |||
Contributor
There was a problem hiding this comment.
Nice readability improvement. :)
Member
Author
There was a problem hiding this comment.
Yeah I think it turned out pretty nice but this change is primarily needed because you can no longer do element instanceof HTMLAnchorElement because the HTMLAnchorElement type available in the renderer is different from the HTMLAnchorElement in the iframe due to sandboxing. This wasn't an issue in the previous logic because we were instantiating elements in the renderer, then stringifying them and having them be recreated in the iframe.
tidy-dev
approved these changes
Jan 12, 2026
Contributor
tidy-dev
left a comment
There was a problem hiding this comment.
💖 Makes sense. I kicked it around via the pull request previewer and some notifications and appears to work great.
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.
Closes #21311
Closes #20760
Description
We're seeing a ton of crashes with no info attached due to the exception reaching us being
null.I tracked it down to our use of
ResizeObserverto observe elements inside of aniframein our SandboxedMarkdown component. It's reproducible in development by hovering over PRs which pops up our PR preview pane. Our prior workarounds for this have failed so I went down the route of trying to avoid usingResizeObserverentirely and instead subscribe to the DOM events that could cause a resize inside of our markdown component.As part of this work and to avoid flickering I reworked our filter pipeline to operate on the iframe Document itself instead of stringifying, parsing, mutating, stringifying etc etc. This lead to much snappier response times and dramatically reduced rerenders.
Screenshots
Release notes
Notes: