fix(variable): stop React reconciling the editable font specimen#14
Draft
posthog[bot] wants to merge 1 commit into
Draft
fix(variable): stop React reconciling the editable font specimen#14posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
The glyph viewer's type specimen is a contentEditable region that rendered its placeholder text as a React child. Once the browser mutates that subtree (typing, IME, or a translation extension), a later render — every weight-slider move rebuilds the div's style, and font switches re-render it — makes React try to remove a text node that has moved out from under it, throwing `NotFoundError: Failed to execute 'removeChild'`. Seed the placeholder once via `dangerouslySetInnerHTML` with a constant string so React treats the editable subtree as opaque and never reconciles the nodes the browser is editing. Generated-By: PostHog Code Task-Id: 9b24f831-baed-47fe-a18a-0195e756a18f
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
The glyph viewer's type specimen on
/variableis acontentEditableregion that rendered its placeholder text as a React child. When the browser mutates that editable subtree — typing, IME composition, or a page-translation extension — a later re-render makes React try to remove a text node that has moved out from under it, throwingNotFoundError: Failed to execute 'removeChild'. The div re-renders on every weight-slider move (itsfontVariationSettingsstyle changes) and on font switches, so the throw is easy to hit after any edit.The fix seeds the placeholder once via
dangerouslySetInnerHTMLwith a module-level constant. React never reconciles adangerouslySetInnerHTMLsubtree while the string is unchanged, so it treats the editable region as opaque and stops competing with the browser for those nodes.suppressContentEditableWarningis dropped since there are no longer any React children.Why
A caught production exception (
removeChildNotFoundError) was reported on the/variablefont tool. It surfaced in the blode.co PostHog project because this child app initializes PostHog with the same project token, but the root cause is here inapps/web/components/glyph-viewer.tsx. The two adjacent dynamic-DOM surfaces flagged for a look —build-tool.tsx(conditional subtree swaps) andfont-preview.tsx(FontFaceinjection into a non-editable preview) — have nocontentEditableand don't participate in this symptom, so they're left unchanged.Test plan
npm run typecheck— passesnpm run check(ultracite format) — passesremoveChildexception; edited text and weight preview both persist.Created with PostHog Desktop from this inbox report.