githubnext/chopinPublic

Let's compose rich plans together

Give a block's two portals a key each

A code, diff or math block hangs two portals off one node: the drawing, and
the row carrying its language and its collapse toggle. Both were keyed with
the Lexical node key, and both are returned from one fragment — so they are
siblings sharing an identity, which React reports as a duplicate key and is
free to resolve by rendering either twice or not at all. Opening a plan with
three such blocks logged it five times, and every keystroke beside one logged
it again: 269 warnings in a single session of typing.

Keeping the keys and distinguishing them by role is the fix rather than
dropping them. A keyed portal is why a block keeps the output it already has
across a commit instead of remounting, which would reset the scroll position
inside a long fence on every character typed elsewhere in the plan.

The two tests are the acceptance the warning was hiding: that all three kinds
of block draw a preview and its chrome when they share a plan, and that a
collapsed fence is still collapsed after an edit somewhere else. Neither can
see the warning itself — the suite runs a production build, where React
strips it — but both fail on the omission it warns about.
MAMaggie Appleton authored
4437ab4Patch
Parent80f9e88
2 files changed+60-2
StackedSplit
e2e/code.e2e.ts+45 −0
packages/editor/src/widgets/render-blocks.tsx+15 −2