Blocks: Avoid setAttributes on end-of-paragraph split#7482
Conversation
|
I've a few things I'm looking into before merging this:
|
core-blocks/paragraph/index.js
Outdated
| } = this.props; | ||
|
|
||
| if ( after ) { | ||
| // After content should be appended to the set of spread blocks as |
There was a problem hiding this comment.
This comment was a bit hard to understand.
There was a problem hiding this comment.
This comment was a bit hard to understand.
Updated in 2ea9199.
mtias
left a comment
There was a problem hiding this comment.
Looks good to me. Thanks for adding comments!
For locked blocks. See also: #6587
Accommodates case where childNodes exist, but none which would qualify after filtering. Also preserves existing logic for detecting / handling paste context.
785bea9 to
7a8ec43
Compare
|
Updates:
|
I think we are stilling making a non required setAttributes call. I added this paragraph as the content of the post: I opened redux dev tools in core/editor store. It is possible to check that we are doing a non required UPDATE_BLOCK_ATTRIBUTES also by inserting many paragraphs without any content. To undo each paragraph creation we need to use undo two times. |
|
@jorgefilipecosta Nice catch. I can reproduce this. However, I think it's a totally separate issue. Namely, we're causing |
This pull request is part of a performance audit of the paragraph block. It seeks to resolve an issue where we needlessly call
setAttributeson a paragraph block when splitting into a new paragraph, and avoids potentially heavy processing withinRichTextto determinebeforeandafterfragments when it can be inferred by the position of the selection at the end/beginning of theRichTextfield whether the existing value can be used verbatim; thus also giving opportunity for the paragraph block to do a strict comparison against its owncontentattribute to determine whethersetAttributesneeds to be called.This is one of two
setAttributescalls which are currently invoked on the original paragraph when pressing enter at the end of its text. The other is explained at #4956 (comment) .Testing instructions:
Verify there are no regressions in the behavior of paragraph splitting.
Optional: Validate that
UPDATE_BLOCK_ATTRIBUTESis dispatched only once (erroneously, vs. twice on master) when pressing enter at the end of a paragraph block using Redux DevTools Extension.