Skip to content
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

Line break remains in RichText after deleting second line #7630

Closed
ktmn opened this issue Jun 29, 2018 · 3 comments
Closed

Line break remains in RichText after deleting second line #7630

ktmn opened this issue Jun 29, 2018 · 3 comments
Labels
[Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Type] Bug An existing feature does not function as intended

Comments

@ktmn
Copy link

ktmn commented Jun 29, 2018

Describe the bug
After adding multiline text to a <RichText> component the content will always receive a trailing <br/> even after the text has been updated to no longer be multiline.

To Reproduce
Steps to reproduce the behavior:

  1. Add a core/button block.
  2. Add content "Hello{enter}{enter}World" to produce a button with multiple lines of text. (note: Already the content is Hello<br/>world<br/>, one <br/> too many)
  3. (optional) Save, refresh...
  4. Delete the text "World" to return the button to a single line of text
  5. (optional) Save, refresh...
  6. Both front and back end, the button's content is Hello<br/> when it should just be Hello

This behavior also exists when the block attribute is saved in comments, not pulled from dom, leaving this in the block comments: {"content":["Hello",{"type":"br","key":"_domReact1","ref":null,"props":{},"_owner":null,"_store":{}}]} when it could simply be {"content":["Hello"]}

Expected behavior

Don't leave a trailing <br/> when going multiline.

Also a <RichText> prop that prevents multiple lines altogether would be useful.

@designsimply designsimply added [Feature] Blocks Overall functionality of blocks [Type] Enhancement A suggestion for improvement. labels Jul 3, 2018
@designsimply
Copy link
Member

Tested and confirmed that adding multiple lines of text to a button and then removing the extra lines leaves an extra <br />.

screen shot 2018-07-02 at mon jul 2 7 16 27 pm
Seen at http://alittletestblog.com/wp-admin/post.php?post=13861&action=edit running WordPress 4.9.6 and Gutenberg 3.1.1 using Firefox 61.0 on macOS 10.13.5.

@mtias mtias added [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... and removed [Feature] Blocks Overall functionality of blocks labels Jul 19, 2018
@ellatrix
Copy link
Member

Does this only happen in Firefox? Then this is a duplicate of #5872. Feel free to reopen if this in not the case.

@ktmn
Copy link
Author

ktmn commented Nov 26, 2018

Nope, Chrome too.

@ellatrix ellatrix reopened this Nov 26, 2018
@ellatrix ellatrix added [Type] Bug An existing feature does not function as intended and removed [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Type] Enhancement A suggestion for improvement. labels Feb 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

5 participants