Repository navigation
fix(blocks): trigger onChange for insertMany - #3050
Open
ZainnQureshii wants to merge 1 commit into
Open
ZainnQureshii wants to merge 1 commit into
ZainnQureshii wants to merge 1 commit into
Conversation
Emit a block-added mutation for each block inserted by BlockManager.insertMany and keep the modifications observer disabled until the initial render finishes, so loading a document stays silent. Fixes codex-team#2874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ZainnQureshii
requested review from
TatianaFomina,
gohabereg,
ilyamore88 and
neSpecc
as code owners
November 14, 2026 13:00
Contributor
There was a problem hiding this comment.
🟢 Approved
No active review issues remain for the change adding insertMany() mutation notifications while keeping initialization silent.
No open issues 🎉
What changed in this PR
Fixes #2874 by making blocks.insertMany() report mutations through onChange, consistent with other block operations, while keeping initial document loading silent.
Changes:
- Emit a
block-addedevent with the correct index for each inserted block. - Start mutation notifications disabled until initialization completes.
- Add regression coverage for batched events, block IDs and indices, and silent initialization; document the fix.
| File | Description |
|---|---|
test/cypress/tests/onchange.cy.ts |
Tests batched insertion events and silent initialization. |
src/components/modules/modificationsObserver.ts |
Starts change notifications disabled. |
src/components/modules/blockManager.ts |
Emits indexed block-added events for bulk insertions. |
docs/CHANGELOG.md |
Records the insertMany() notification fix. |
Review effort: Balanced
neSpecc
reviewed
Nov 14, 2026
| /** | ||
| * Flag shows onChange event is disabled | ||
| */ | ||
| private disabled = false; |
Member
There was a problem hiding this comment.
this seems unexpected. I'd suggest explicitly call disable/enable on initial render.
Member
There was a problem hiding this comment.
make sure it is covered by tests
This branch has not been deployed
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.
Fixes #2874
blocks.insertMany()inserted the blocks but never reported them, soonChangestayed silent whileinsert,deleteandmoveall fire it.BlockManager.insertManynow emits ablock-addedevent for each inserted block, with its own index, and the observer batches them into oneonChangecall as it does for other mutations.The renderer also loads the initial document through
BlockManager.insertMany, soModificationsObservernow starts disabled (disabled = true) and is switched on bycore.tsafter the first render, asblocks.render()and the read-only toggle already do around their re-renders. Loading a document therefore stays silent, and the existing "should not be called on initialization" tests still pass.Changes:
src/components/modules/blockManager.ts: emitblock-addedfor each block ininsertMany.src/components/modules/modificationsObserver.ts: start disabled until the editor is ready.test/cypress/tests/onchange.cy.ts: regression test for one batched call with both inserted blocks, their ids and indices 1 and 2, and no call on initialization.docs/CHANGELOG.md: oneFixline under 2.32.0.How it was checked (Node 18.20.1 from
.nvmrc):yarn lintandyarn buildpass.nextand passes with the change.yarn test:e2e: 30 specs, 283 tests passed and none failed before the local Electron tab crashed onui/toolbox.cy.ts; the remaining 10 specs were rerun on their own: 86 passed, 1 failed. The failure isutils/flipper.cy.ts"should prevent plugins event handlers from being called while keyboard navigation" (Cannot set properties of undefined (setting 'selected')inselectBlock), and it fails the same way onnextwithout this change.Prepared with AI assistance (Claude Code) and reviewed with GitHub Copilot.
🤖 Generated with Claude Code