Resolve Blocks by holder identity instead of working-area child index#3009
Open
joecrop wants to merge 1 commit into
Open
Resolve Blocks by holder identity instead of working-area child index#3009joecrop wants to merge 1 commit into
joecrop wants to merge 1 commit into
Conversation
BlockManager.getBlock() and setCurrentBlockByChildNode() resolved a Block by taking indexOf(wrapper) over Blocks.nodes — which is Array.from(workingArea.children) — and using that position to index the blocks array. The two lists are only aligned when the working area contains nothing but Block holders. When a host application adds non-block elements between blocks (visual decorations such as page-break spacers in a paginated view), every Block below such an element resolves to the wrong index: the editor marks the wrong Block as current, and for the last Block the index lands past the end of the blocks array, throwing TypeError: Cannot read properties of undefined (reading 'updateCurrentInput') on any click into the block or below it (Ui.processBottomZoneClick → Caret.setToTheLastBlock, and Ui.selectionChanged). Both methods now find the Block by holder identity, the same idiom already used by getBlockByChildNode() and RectangleSelection. setCurrentBlockByChildNode() also returns undefined for a wrapper element that matches no managed Block instead of corrupting currentBlockIndex, matching its documented return type. Adds a mousedown regression test that inserts a non-block element into the redactor and clicks the block below it — it fails with the updateCurrentInput TypeError before this change. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
BlockManager.getBlock() and setCurrentBlockByChildNode() resolved a Block by taking indexOf(wrapper) over Blocks.nodes — which is Array.from(workingArea.children) — and using that position to index the blocks array. The two lists are only aligned when the working area contains nothing but Block holders. When a host application adds non-block elements between blocks (visual decorations such as page-break spacers in a paginated view), every Block below such an element resolves to the wrong index: the editor marks the wrong Block as current, and for the last Block the index lands past the end of the blocks array, throwing
TypeError: Cannot read properties of undefined (reading 'updateCurrentInput')
on any click into the block or below it (Ui.processBottomZoneClick → Caret.setToTheLastBlock, and Ui.selectionChanged).
Both methods now find the Block by holder identity, the same idiom already used by getBlockByChildNode() and RectangleSelection. setCurrentBlockByChildNode() also returns undefined for a wrapper element that matches no managed Block instead of corrupting currentBlockIndex, matching its documented return type.
Adds a mousedown regression test that inserts a non-block element into the redactor and clicks the block below it — it fails with the updateCurrentInput TypeError before this change.