fix(editors): hoist ToolbarButton (static-components ×9) + restore live toolbar active states - #88
Merged
Conversation
…ar active states Two fixes to the rich-text/collab editor toolbars (#38 batch 1 of 3): - ToolbarButton was declared inside both editors' render, so React saw a new component type every render and remounted the buttons each time (react-hooks/static-components, 9 warnings — all gone). The two copies were identical; they're now one shared module-scope component (ui/editor-toolbar-button.tsx). - Found during verification: toolbar active-state highlights have been frozen since the TipTap 3 migration (#69) — v3's useEditor no longer re-renders the host component on editor transactions (v2 did; the compat flag is marked legacy). Active flags are now derived via useEditorState, which re-renders exactly when a selected flag changes. Live-verified in both editors: bold/H2 highlight on selection, track toggle on/off, focus stays in the editor. Co-Authored-By: Claude <noreply@anthropic.com>
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.
Batch 1 of 3 for #38.
Lint fix:
ToolbarButtonwas declared inside both editors' render bodies — a new component type every render, so React remounted the button subtree each parent render (react-hooks/static-components, 9 warnings → 0). The two definitions were byte-identical; they're now one shared module-scope component. Warning count: 28 → 18, other rules untouched.Bug found during live verification: toolbar active-state highlights have been frozen since the TipTap 3 migration (#69) — v3's
useEditordefaultsshouldRerenderOnTransactiontofalse(marked legacy-to-be-removed), soeditor.isActive(...)evaluated in render never refreshed. Fixed the v3-idiomatic way:useEditorStatewith a selector over the active flags, re-rendering exactly when a flag flips (React-Compiler-friendly, per-keystroke-re-render-free).Verification (demo stack, both editors):
tscclean · eslint 0 errors / 18 warnings (the remaining Burn down the 27 react-hooks v7 (React Compiler) lint warnings #38 batches) · vitest 130/130 · production build untested locally (CI covers it).🤖 Generated with Claude Code