-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rich Text: Determine emptiness by value #5091
Conversation
blocks/rich-text/index.js
Outdated
@@ -397,8 +395,7 @@ export class RichText extends Component { | |||
*/ | |||
|
|||
onChange() { | |||
this.isEmpty = this.editor.dom.isEmpty( this.editor.getBody() ); | |||
this.savedContent = this.isEmpty ? [] : this.getContent(); | |||
this.savedContent = this.getContent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this change is creating some issues, you can't reproduce with consistency but some times when you split a paragraph and then empty one of these two paragraphs you'll end up with an empty paragraph but not really considered empty since the inserter doesn't show up.
We might want the filtering behavior like you said.
Could we maybe still leave the TinyMCE empty check in place, but still look at the value when rendering instead of creating a new property? Should have done that in the undo PR because the property makes little sense. I think will still have to either check for emptiness or filter out empty nodes, in which case the question becomes which one is more performant? |
I think we'll want both changes eventually, but agree it could have been done in separate steps.
Well, we should want to be consistent in either case. Looking at the implementation of |
@aduth What's left to do here? Do we still want this? Or do we want if done differently? |
@iseulde I think we do want this, as |
059d8ba
to
f9f2739
Compare
Rebased to resolve conflicts, and changed base to In f9f2739, I applied child node filtering during a split to both the I've played around a bit and am not able to find any other cases where this could occur. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also played around this and it seems to work as intended. I believe we can probably add an e2e test to check that the side inserter is still showing using different ways to create empty paragraphs.
f9f2739
to
26be694
Compare
I went further in 26be694 after noticing we have many different touch points considering emptiness in different ways. With #4955 keeping the value should in sync, when the editor is empty the value should never be anything other than an empty array. If it is, that's a bug, and should be addressed directly. With I also suspect many of the functions changed may be simply remnants of the pre-#4955 state of the component where we couldn't rely on an up-to-date |
That sounds good. I'm fine with trying this. |
Thanks @iseulde and @youknowriad ! |
Note: This pull request has
try/undo-buffer
(#4956) assigned as a base for easier future merging.This pull request seeks to remove assignment of a
this.isEmpty
instance property in theRichText
component, and in doing so, avoids calculating emptiness on change.Open questions:
It's unclear when we'd ever expect
this.isEmpty
to have been assigned astrue
inonChange
wheregetContent
would otherwise not return an empty array. If this is still possible, I'd be inclined to consolidate filtering recently applied for block splitting viafilterEmptyNodes
(#5034).Testing instructions:
Repeat testing instructions from #5034
Verify that the RichText placeholder is shown when expected: when the block is not selected and is empty.