Skip to content

Block Editor: Stop duplicate controllers from taking the selection - #82706

Open
jeryj wants to merge 12 commits into
trunkfrom
fix/duplicate-block-scroll
Open

jeryj wants to merge 12 commits into
trunkfrom
fix/duplicate-block-scroll

Conversation

@jeryj

@jeryj jeryj commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

What?

Closes #79096

When two blocks render the same entity — two Navigation blocks using the same menu, or two Post Content blocks in "Show template" mode — editing one made the other take the selection, scrolling the canvas to it and pulling the caret out of the block being typed in. In the Site Editor the caret snapped back after every keystroke, so typed text came out reversed, and each character became its own undo level.

Why?

Each inner block controller keeps private clones of its entity's blocks, but every controller of the same entity maps the same external IDs. When one of them is edited, the others receive the change as an incoming value, re-clone their whole subtree, and then restore the entity's recorded selection onto their own clones. Each of them recognises that selection as its own, so the last one to sync steals it.

The re-clone on every keystroke also caused the rest: replacing the duplicate's blocks between two keystrokes broke the isUpdatingSameBlockAttribute chain in the persistence reducer, and the duplicate's RichText fields saw their html change from outside and marked the last change persistent, ending the typing run.

How?

Four changes, one per layer:

  1. Selection guard, useBlockSync. After syncing an incoming value, skip restoring the recorded selection when the block-editor's current selection already sits inside a different controller. The holder is the nearest controlled ancestor of the selected block, found with getBlockParents. A selection in the root block list belongs to no controller, so it never blocks a restore, and a selection this controller just destroyed by re-cloning is still repaired.
  2. In-place update, useBlockSync. When the incoming value has the same structure as the current clones (same external IDs, same block names, same order, all the way down), apply only the changed attributes to the existing clones as one history-ignored update instead of re-cloning. The mapping, the mounted components and the selection all stay valid between keystrokes. Structural changes still re-clone.
  3. Persistence reducer. A history-ignored change that leaves the blocks of the previous action untouched no longer resets the "last action", so a typing run survives the duplicate's mirror update. A change that does replace those blocks, such as a reset after an undo, still starts a new level: the undo manager appends staged edits to the previous level, so the first keystroke after a reset has to stay persistent.
  4. useMarkPersistent. Only a selected field is typed or formatted in, so a change reaching an unselected field comes from elsewhere. The hook now takes isSelected and only marks from a selected or multi-selected field. Unselected fields keep tracking the value so nothing is misjudged once they are selected again.

Credit

Similar to @ramonjd's approach from #79422 and #79929.

Testing Instructions

  1. In the Site Editor, add two Navigation blocks that use the same menu, with enough content between them that the second is off screen.
  2. Click into a menu item label in the first block and type.
  3. The text appears in the order typed, the selection stays in the first block, and the canvas does not scroll to the duplicate.
  4. Add a menu item to the first block. The selection stays in the first block.
  5. Press undo. The whole typed run is removed at once and the caret stays in the first block.
  6. Repeat with a page and its template in "Show template" mode, with one Post Content at the template root and another inside a Template Part.

Automated

  • navigation-selection-sync.spec.js (new) — the reproduction. It records every selection entering the duplicate rather than asserting on the final selection: the steal is often momentary, and the canvas scrolls as soon as it happens even when the selection recovers. A final-state assertion passed 4 runs in 5.
  • post-content-focus-mode.spec.js — the same for duplicate Post Content instances, plus undo moving the caret between blocks of one Post Content.
  • site-editor/undo.spec.js — typing in a duplicated container keeps every character, and undo removes the whole run. A test.fixme pins the pre-existing gap described under "Out of scope".
  • Existing coverage constrains the guard from being too broad: forcing it to always skip fails patterns.spec.js → "should restore selection after navigating back from pattern editing", which restores a selection inside the Post Content controller.
  • Unit tests cover the in-place update and the structural re-clone (use-block-sync), the reducer rule for ignored changes to other blocks (store/test/reducer.ts), and the unselected-field rule (use-mark-persistent).
npm run test:e2e -- test/e2e/specs/site-editor/navigation-selection-sync.spec.js
npm run test:e2e -- test/e2e/specs/editor/various/post-content-focus-mode.spec.js
npm run test:e2e -- test/e2e/specs/site-editor/undo.spec.js
npm run test:e2e -- test/e2e/specs/editor/various/undo.spec.js
npm run test:e2e -- test/e2e/specs/editor/various/patterns.spec.js

Out of scope

  • Undo does not move the caret into a nested entity, with or without duplicates. A controller records its selection against its own entity, but the only consumer of a recorded selection reads the root record. Pre-existing and unrelated to duplicates; worth its own issue. Pinned as a test.fixme in site-editor/undo.spec.js.
  • A block's isValid is not mirrored by the in-place update. Recovering an invalid block in one container leaves the duplicate's clone flagged invalid until the next structural sync. Edge case; the previous full re-clone did carry it over.

🤖 Generated with Claude Code

https://claude.ai/code/session_017RtcwXT84eF6zLdQXK9e1W
https://claude.ai/code/session_01UpQLN4sQKUDBA45FqsyUQY

@jeryj
jeryj requested a review from ellatrix as a code owner September 9, 2026 21:09
@github-actions github-actions Bot added the [Package] Block editor /packages/block-editor label Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: jeryj <jeryj@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: Mustafabharmal <mustafabharmal@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

📦 Bundle size

Size Change: +309 B (0%)

Total Size: 8.88 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 597 kB +309 B (+0.05%)

acbbdb3 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 9b9ebfc trunk % Change
timeToFirstByte 56 ms +11.07% -5% 54.2 ms +17.8% -2.68% 3.32%
largestContentfulPaint 100 ms +2% -4% 96 ms +6.25% -6.25% 4.17%
lcpMinusTtfb 42.9 ms +7.23% -16.08% 36.8 ms +17.53% -7.74% 16.58%
wpBeforeTemplate 28.9 ms +19.97% -2.18% 28.9 ms +20.24% -2.35% 0%
wpTemplate 21.54 ms +4.41% -2.83% 21.09 ms +10.15% -2.47% 2.13%
wpTotal 49.7 ms +16.16% -0.56% 50.51 ms +17.42% -3.09% -1.6%
wpMemoryUsage 7.61 MB +0% -0% 7.57 MB +0% -0% 0.57%
wpDbQueries 17 +0% -0% 17 +0% -0% 0%

front-end-classic-theme

Metric 9b9ebfc trunk % Change
timeToFirstByte 46.35 ms +9.71% -1.51% 42.25 ms +8.64% -1.07% 9.7%
largestContentfulPaint 104 ms +1.92% -3.85% 92 ms +4.35% -2.17% 13.04%
lcpMinusTtfb 55.85 ms +3.67% -2.78% 49.8 ms +0.8% -2.71% 12.15%
wpBeforeTemplate 26.79 ms +13.36% -1.94% 26.71 ms +3.67% -0.52% 0.3%
wpTemplate 16.55 ms +4.35% -3.2% 12.5 ms +6% -1.52% 32.4%
wpTotal 43.18 ms +9.52% -2.06% 39.17 ms +9.11% -0.82% 10.24%
wpMemoryUsage 6.28 MB +0% -0% 6.12 MB +0% -0% 2.54%
wpDbQueries 14 +0% -0% 10 +0% -0% 40%

media-processing

Metric 9b9ebfc trunk % Change
mediaProcessingJpeg 411.57 ms +0.14% -0.88% 404.58 ms +0.22% -0.33% 1.73%
mediaProcessingAvif 6075.82 ms +0.29% -0.2% 6078.86 ms +0.08% -0.24% -0.05%
mediaProcessingJpegToAvif 4186.65 ms +0.19% -0.2% 4181.73 ms +0.03% -0.16% 0.12%

media-upload

Metric 9b9ebfc trunk % Change
jpegUploadProcessing 1470.41 ms +31.31% -2.34% 1442.71 ms +0.61% -1.89% 1.92%
pngUploadProcessing 211.43 ms +13.15% -11.86% 226.29 ms +1.57% -17.57% -6.57%
largeJpegUploadProcessing 1416.11 ms +0.4% -0.31% 1415.43 ms +1% -0.58% 0.05%
multipleImageUploadProcessing 1592.56 ms +7.93% -1.11% 1579.12 ms +8.8% -0.16% 0.85%

post-editor

Metric 9b9ebfc trunk % Change
serverResponse 502.14 ms +6.66% -8.16% 505.99 ms +3.67% -3.61% -0.76%
firstPaint 514.36 ms +2.04% -25.74% 483.05 ms +8.25% -33.71% 6.48%
domContentLoaded 1175.62 ms +1.26% -1.46% 1184.21 ms +3.38% -2.04% -0.73%
loaded 1176.98 ms +1.24% -1.46% 1185.7 ms +3.37% -2.03% -0.74%
firstContentfulPaint 514.36 ms +2.04% -20.04% 521.22 ms +1.26% -3.58% -1.32%
firstBlock 3544.14 ms +0.59% -0.82% 3535.2 ms +0.68% -1.48% 0.25%
type 18.43 ms +6.29% -4.45% 17.97 ms +2.95% -4.95% 2.56%
typeWithoutInspector 17.25 ms +9.39% -1.51% 18.51 ms +5.19% -3.51% -6.81%
typeWithTopToolbar 23.81 ms +2.73% -3.11% 23.69 ms +9.12% -7.85% 0.51%
typeContainer 8.57 ms +4.55% -1.4% 8.9 ms +7.19% -6.97% -3.71%
focus 119.78 ms +8.15% -3.47% 116.32 ms +1.81% -2.88% 2.97%
firstFocus 252.84 ms +0% -0% 223.35 ms +0% -0% 13.2%
selectAll 591.61 ms +0.82% -0.79% 581.62 ms +3.31% -1.19% 1.72%
listViewOpen 76.62 ms +9.44% -7.83% 82.24 ms +9.75% -6.65% -6.83%
inserterOpen 39.89 ms +20.56% -7.9% 41.45 ms +5.26% -4.87% -3.76%
inserterHover 11.56 ms +13.93% -10.47% 11.96 ms +8.78% -11.2% -3.34%
inserterSearch 8.58 ms +13.05% -4.2% 8.18 ms +7.09% -2.57% 4.89%
loadPatterns 662.92 ms +2.55% -5.05% 628.65 ms +7.77% -1.06% 5.45%
wpTotal 491.87 ms +6.47% -8.29% 495.81 ms +3.77% -3.61% -0.79%
wpMemoryUsage 13.42 MB +0% -0% 13.26 MB +0% -0% 1.21%
wpDbQueries 54 +0% -1.85% 54 +0% -1.85% 0%

site-editor

Metric 9b9ebfc trunk % Change
serverResponse 321.1 ms +2.39% -8.63% 317.92 ms +1.79% -4.99% 1%
firstPaint 213.54 ms +7.42% -24.2% 191.32 ms +25.23% -11.16% 11.61%
domContentLoaded 1004.5 ms +3.33% -0.47% 980.06 ms +2.12% -1.22% 2.49%
loaded 1005.6 ms +3.33% -0.46% 981.14 ms +2.13% -1.22% 2.49%
firstContentfulPaint 425.56 ms +5.4% -1.72% 421.8 ms +0.95% -1.74% 0.89%
firstBlock 3693.3 ms +1.42% -1.35% 3561.72 ms +0.68% -1.04% 3.69%
type 16.01 ms +4.25% -2.5% 16.21 ms +1.48% -2.04% -1.23%
navigate 96.48 ms +6.52% -6.87% 103.2 ms +6.63% -6.41% -6.51%
loadPatterns 1146.99 ms +10.63% -10.15% 1165.47 ms +2.92% -8.63% -1.59%
loadPages 1074.47 ms +2.86% -1.16% 1092.29 ms +6.96% -2.01% -1.63%
wpTotal 312.64 ms +2.46% -8.82% 309.22 ms +1.89% -5.01% 1.11%
wpMemoryUsage 12.47 MB +0% -0% 12.32 MB +0% -0% 1.22%
wpDbQueries 43 +2.33% -0% 43 +2.33% -0% 0%

acbbdb3 Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

should leave the rest of the list intact when merging into an empty list item in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  -  0
+ Received  + 13

@@ -5,27 +5,40 @@
          "attributes": Object {
            "content": "1",
          },
          "innerBlocks": Array [
            Object {
+             "attributes": Object {
+               "ordered": false,
+               "values": "",
+             },
              "innerBlocks": Array [
                Object {
                  "attributes": Object {
                    "content": "a",
                  },
+                 "innerBlocks": Array [],
                  "name": "core/list-item",
                },
                Object {
                  "attributes": Object {
                    "content": "b",
                  },
+                 "innerBlocks": Array [],
                  "name": "core/list-item",
                },
              ],
              "name": "core/list",
            },
          ],
+         "name": "core/list-item",
+       },
+       Object {
+         "attributes": Object {
+           "content": "",
+         },
+         "innerBlocks": Array [],
          "name": "core/list-item",
        },
      ],
      "name": "core/list",
    },
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:3118:38

acbbdb3 Run

// belongs and there is no need to walk the tree for it.
if (
idMappingRef.current.internalToExternal.has( currentStartClientId )
) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll get back to this later, but my guess is that this PR probably breaks undo/redo selection restoration when you do multiple consecutive changes within the same controlled container. Basically an undo call might ask for the selection to move to another block within that same controlled container but the current PR will prevent it from happening.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm at my EOD and had my agent write a test to try to cover this. I'll be back tomorrow to give it another try if it is an issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this out and pushed more Claude Fable work. It's testing well but I'm unsure about the direction without diving deeply into it since I'm not familiar with this part of the code. I've got it pushed up and will start going through it. I've tested it, and it is in a better state than trunk. Here's the current state:

  • Fixes duplicate container stealing the block selection
  • Doesn't cause the "backwards typing" bug
  • Does not cause an undo regression. There is already an issue on trunk with undo in a container not appropriately selecting and moving the caret to the correct location. I'll file that issue shortly.

Fable's summary of the fixes:

  1. Selection guard, useBlockSync. After a sync, skip restoring the entity's recorded selection when the current selection already sits in a different controller. Stops the other copy taking the caret.
  2. In-place update, useBlockSync. When the incoming value has the same structure as the current clones, apply the changed attributes to them as one history-ignored update instead of re-cloning and replacing. Removes the per-keystroke rebuild that caused every symptom. Structural changes still rebuild.
  3. Persistence reducer. A history-ignored change that leaves the typed block untouched no longer resets the "last action", so a typing run survives the other copy's mirror update. An undo still ends it.
  4. useMarkPersistent. Read the live RichText record via getValue instead of the render-time one, which is a change behind when the html changes from outside. Otherwise an external text change is mistaken for a formatting change and ends the run.

jeryj added a commit that referenced this pull request Sep 9, 2026
Per review on #82706: check that an undo can still move the selection
from one block of a controlled container to another. Post Content is an
inner block controller, so two of its blocks exercise that path.

Passes identically with the guard enabled and disabled, five runs each.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RtcwXT84eF6zLdQXK9e1W
@ramonjd

ramonjd commented Sep 9, 2026

Copy link
Copy Markdown
Member

Thanks for driving this forward @jeryj! 🍺

I had another rando draft open to try to solve the undo conundrum here too:

I ran out of time to look at this, so I'll close that in favour of this one.

There's also a contributor PR that hasn't moved much #79097

jeryj and others added 10 commits October 15, 2026 11:21
Adds failing coverage for #79096 and regression guards for the behaviour
a fix must not break.

Two blocks rendering the same entity (two Navigation blocks on one menu,
two Post Content instances) each clone that entity's blocks privately but
build identical external-to-internal ID maps. In useBlockSync's
restoreSelection, ownership is decided by whether the external ID appears
in that map, which every such controller answers true to, so an edit in
one instance is followed by the other claiming the selection.

Failing (the defects):
- editing a menu item leaves the caret and selection in the edited block
- undoing a menu edit returns the caret to the block that made it
- undo moves the caret back into the Navigation block when the caret has
  moved outside it
- typing in one Post Content instance leaves the caret and selection in
  that instance

The last two are a second, separate gap: a nested controller records its
selection against its own entity, but the only consumer of a recorded
selection reads the root record, so cross-controller undo never restores
the caret.

Passing (guards for existing behaviour):
- undo restores the caret to the undone block when another block is
  selected
- selection is restored after returning from a template part

The duplicate tests record every selection entering the other instance
rather than asserting on the final selection: the steal is often
momentary, and the canvas scrolls as soon as it happens even when the
selection recovers. A final-state assertion passed 4 runs in 5.

The Navigation spec is adapted from
#79929.

Also makes Template Part Focus mode activate its theme per test; the
theme was restored after each test but only activated in beforeAll, so
any second test in the file ran against the wrong theme.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RtcwXT84eF6zLdQXK9e1W
Fixes #79096.

Two blocks can render the same entity — two Navigation blocks using one
menu, a Post Content block at a template root and another inside a
template part. Each is an inner block controller holding private clones,
but both clone the same blocks, so both build the same
external-to-internal ID mapping and both recognise the entity's
selection as their own.

An edit in one instance therefore reaches the other as an incoming
entity change. That controller re-clones and calls restoreSelection,
which converts the external ID to its own copy and dispatches
resetSelection. The canvas scrolled to the duplicate and the caret left
the block being typed in, reliably enough to reorder characters.

Guard the restoreSelection call instead: when the selection already sits
inside a different inner block controller, this sync is a consequence of
an edit made there, so leave it alone. The controller that made the edit
takes the outgoing branch and never reaches this code, so a selection
held by another controller is always one that has been dealt with. A
selection held by the root block list belongs to no controller and still
restores as before, which is what keeps entity navigation and undo
working.

The guard sits at the call site rather than inside restoreSelection: the
question is about the sync that just happened, not about the selection
object, and restoreSelection keeps its existing contract.

This reuses getBlockParents and areInnerBlocksControlled, already
selected in this hook, so there is no new store state, no new action or
selector, and nothing persisted into entity data or collaborative state.

Revives the approach in #79422 by @ramonjd, which asked the same question
with the same selectors and was closed by its author in favour of #79097.
Two differences: the check moved to the call site, and the WeakMap
remembering the last controller to hold the selection is left out.

Also removes two tests added with the failing coverage. They asserted
that undo returns the caret to the block whose edit was undone. Trunk
does not do that for any nested entity, with or without duplicates: a
controller records its selection against its own entity, but the only
consumer of a recorded selection reads the root record. That is a
separate, pre-existing gap and out of scope here.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RtcwXT84eF6zLdQXK9e1W
…root

getBlockParents collects every ancestor up to the document root and is
memoized on state.blocks.parents, which changes on each re-clone, so the
memo never hits on this path. The answer is almost always the immediate
parent, since a menu item sits directly inside its Navigation block.

Walk up with getBlockRootClientId instead, stopping at the first
controller, and short-circuit on the controller's own mapping when the
selected block is one of its clones.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RtcwXT84eF6zLdQXK9e1W
The existing comment describes restoreSelection, so it belongs inside the
guard rather than above it. Also records why the guard is checked after
the blocks are set.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RtcwXT84eF6zLdQXK9e1W
Per review on #82706: check that an undo can still move the selection
from one block of a controlled container to another. Post Content is an
inner block controller, so two of its blocks exercise that path.

Passes identically with the guard enabled and disabled, five runs each.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RtcwXT84eF6zLdQXK9e1W
Two Template Parts pointing at the same entity are both inner block
controllers synced from one record. These pin the two behaviours that
matter when typing into one of them.

The first passes: every typed character survives, in both copies. That is
the behaviour the preceding commits on this branch fixed, and it
regresses silently, so it is worth holding down.

The second fails. One undo removes a single character rather than the
whole typed run, because each keystroke makes the *duplicate* run
setControlledBlocks() and dispatch replaceInnerBlocks. That action lands
between keystrokes and breaks the isUpdatingSameBlockAttribute merge
chain, so every character becomes its own undo level. Marking the change
not-persistent does not help: any intervening action on another block
breaks the chain regardless. restoreSelection is not involved — the
existing guard keeps it from firing during typing.

Both tests type at a human cadence on purpose. An instant
keyboard.type() outruns the re-sync and passes, so the delay is
load-bearing rather than incidental.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UTowaGipHSMef7nUQAnnJJ
Two containers rendering one entity, such as two Template Parts on the
same slug, are both inner block controllers. Typing in one edits the
entity, and the other mirrors the edit onto its own clones as a change
ignored by history. The persistence reducer still recorded that change
as the last action, so the next keystroke no longer looked like a
continuation of the run and was filed as a new undo level. Undo then
removed one character at a time.

A history-ignored change that leaves the last-updated block's entry and
attributes untouched now keeps the previous last action, so the run
continues across it. A change that does replace that block, such as the
reset after an undo, still starts a new level.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A6LxkvDuGJg68a7c8KJKry
useMarkPersistent decides between "text input, wait a second" and
"formatting change, end the run now" by comparing the record's text with
the text it saw last. When the html changes from outside the rich text,
useRichText applies it to its record in a layout effect of its own, so
the record handed to the hook at render time is one change behind. The
hook then saw new html with the old text and ended the run at once.

Read the live record inside the effect instead, through the getValue
that useRichText already returns.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A6LxkvDuGJg68a7c8KJKry
…tes change

An inner block controller rebuilt its whole subtree whenever its entity
changed: it cleared the ID mapping, cloned every block under a fresh
client ID and replaced the inner blocks. With two containers rendering
one entity, that happened on every keystroke made in the other one. Each
keystroke tore down and remounted every block and rich text in the
duplicate, briefly left it without a selection, and dispatched a block
replacement into the store between two keystrokes.

When the incoming value has the same structure as the current clones,
the same external IDs in the same order, the controller now applies the
changed attributes to the existing clones as one history-ignored update.
The mapping, the mounted components and the selection stay valid. A
structural change still takes the rebuild path.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A6LxkvDuGJg68a7c8KJKry
An undo that reverts an edit in one Template Part while the caret sits in
another should bring the caret back to the reverted block, as it does at
the root of the document. It does not yet: a nested controller only
restores the selection recorded on the root record, which an undo of its
own entity never changes. The test is marked fixme to document the gap.

The duplicated-container tests now also delete saved templates when they
finish, since a leftover saved index template made their setup fail.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A6LxkvDuGJg68a7c8KJKry
@jeryj
jeryj force-pushed the fix/duplicate-block-scroll branch from 70180df to 13b223b Compare October 15, 2026 16:33
jeryj and others added 2 commits October 15, 2026 13:13
The nearest controlled ancestor of the selected block is its holder. The store already has an ascending parent list, so use that instead of walking the tree by hand.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UpQLN4sQKUDBA45FqsyUQY
A field that is not selected is never typed or formatted in, so a change reaching it comes from elsewhere, such as another container editing the same entity. Ignore it instead of reading the live rich text record to tell it apart from formatting.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UpQLN4sQKUDBA45FqsyUQY

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding an item to a duplicate Navigation Block scrolls the second one into view

3 participants