Cannot delete all text from multiline RichText field
Describe the bug It is impossible to delete all of the text from a multiline RichText field. If I highlight all of the text and delete it, the text is deleted from the editor, but when I save and view the page, the original text is still there.
I first discovered the issue in a custom block that I am developing, but I am able to reproduce in out-of-the-box blocks, like Quote.
To Reproduce Steps to reproduce the behavior:
- Go to a page and add the Quote block.
- Add content to the quote part of the block (i.e. where it says "Write quote...".
- Highlight all of that content and press Delete on your keyboard.
- The content is no longer in the block on the edit screen.
- Save and view the page.
- Note that the deleted content appears on the front end.
Note: I was also able to reproduce in the Pull Quote block and the caption on the Image block.
Expected behavior The deleted content should not appear on the front-end.
Desktop (please complete the following information):
- OS: Mac OS
- Browser: Chrome (latest)
Additional context
- Tested on Gutenberg 4.7.0.
I'm able to reproduce this in Mac OSX using the latest Chrome in both the Pull Quote block and in a custom multiline block.
Note: If you delete the content one character at a time, it seems to work. If you highlight the line of text and delete, it does not.
Is this still an issue with the latest master branch, after #13697? I cannot reproduce any longer.
Still an issue under the version of Gutenberg shipped with WordPress 5.1. Same comment as @jeremyfelt .
Chrome 72, OSX 10.14.3, WP 5.1.
Deleting one char at a time USUALLY works. It has to do with spaces. Selecting all text and deleting at once won't trigger onChange, nor will make the placeholder visible.
Please see the following capture from a :
<RichText
multiline="p"
inlineToolbar="true"
value={ description }
placeholder={ __( 'Description', 'myi18n' ) }
onChange={ ( value ) => { console.log( value ); setAttributes( { description: value } ) } }
id={inputId}
/>
Second test is adding five spaces, and removing them ONE BY ONE. The RichText deleted them all AT ONCE without triggering the onChange, leaving the value to 5 spaces. Third test is selecting all context and deleting it, also not triggering the onChange.

I do not know if it's related, but there is an inconsistency in the value of a RichText, in that way.
A newly created one will have a content equal to an empty string. One in which we removed all data (100% empty) will have <p></p> content data. Both empty, different data.
@iseulde , is the master different than the version shipped in 5.1? If so, how to test this version?
You can test the latest Gutenberg version by installing the plugin. It’s updated more often than WordPress. Thanks!
On Wed, 27 Feb 2019 at 13:29, Bérenger [email protected] wrote:
@iseulde https://github.com/iseulde , is the master different than the version shipped in 5.1? If so, how to test this version?
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/WordPress/gutenberg/issues/12880#issuecomment-467844168, or mute the thread https://github.com/notifications/unsubscribe-auth/AEfg67dVoBnsXsC8ml59xPd5t92DS3yXks5vRnozgaJpZM4ZT1YH .
Did so. The issue first mentioned in the ticket is indeed fixed under 5.1.1. All the previous tests are conclusive. There is still this discrepancy between the initial state (which will return an empty string) and "empty state" (which will return
). Will check in the other issues if it exists. Thank you!
@berengerzyla Do you mean that for multiline instances it will return e.g. <p></p>? This has been brought up in https://github.com/WordPress/gutenberg/pull/10678#discussion_r226456573 and there's a tracking issue #10763. Thanks for testing!
Since you created #14160, I'm going to close this issue.