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

RichText: warn when using inline tagName #11839

Closed
p2er opened this issue Nov 14, 2018 · 5 comments · Fixed by #13921
Closed

RichText: warn when using inline tagName #11839

p2er opened this issue Nov 14, 2018 · 5 comments · Fixed by #13921
Assignees
Labels
[Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable Needs Technical Feedback Needs testing from a developer perspective.

Comments

@p2er
Copy link

p2er commented Nov 14, 2018

Describe the bug
Create a RichText node in edit function. Fill with text content. Remove text with backspace key (selecting the text and deleting it all together does not cause this issue).

To Reproduce
Steps to reproduce the behavior:
0. Create Richtext, e.g.

<RichText
	tagName={ 'span' }
	value={ citation }
	placeholder={ __( 'Write citation…' ) }
	onChange={
		( nextCitation ) => setAttributes( {
			citation: nextCitation,
		} )
	}
/>
  1. Enter content into rich text field
  2. Safe Document
  3. Reload
  4. Click into text
  5. Delete text by hitting backspace multiple times
  6. Last digit can not be removed

Error occurs:
index.js?ver=1542114671:1 The given range isn't in document.

Expected behavior
Text should be cleared if user tries to delete content letter by letter with backspace.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: macOS 10.14.1
  • Browser: all

Additional context

  • Gutenberg Version 4.3.0
  • Wordpress Version 4.9.8
@p2er
Copy link
Author

p2er commented Nov 14, 2018

I was able to narrow down the problem. In the current quote/pullquote implementation the richtext is only rendered if isSelected is true or richtext is not empty { ( ! RichText.isEmpty( citation ) || isSelected ) && (...) }
The problem occurs If this code is removed and the tagName Attribute is present on the richtext.

@ktmn
Copy link

ktmn commented Nov 14, 2018

<RichText
	tagName={ 'span' }

Does it also happen with div? Inline elements and richtext/tinymce don't work well together.

@designsimply designsimply added [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable Needs Technical Feedback Needs testing from a developer perspective. labels Nov 14, 2018
@ellatrix
Copy link
Member

Sounds like we'll have to start warning on the use of RichText with inline elements.

@ellatrix ellatrix self-assigned this Nov 21, 2018
@ellatrix ellatrix changed the title RichText throws JS Error if cleared letter by letter with backspace RichText with inline wrapper element: throws JS Error if cleared letter by letter with backspace Nov 21, 2018
@ellatrix ellatrix changed the title RichText with inline wrapper element: throws JS Error if cleared letter by letter with backspace RichText: warn when using inline tagName Nov 26, 2018
@vicolaspetru
Copy link

vicolaspetru commented Dec 16, 2018

So, is there a way to fix this bug? I have the same problem when delete text by hitting backspace multiple times. :(

@ellatrix
Copy link
Member

@vicolaspetru you shouldn't use RichText with tagName=span.

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 Needs Technical Feedback Needs testing from a developer perspective.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants