Repository navigation
(RichText)(Workaround)(17.1.x) Fallback to a string arg in collapseWhiteSpace() if value is not a string - #56570
Conversation
|
Size Change: +5 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
…id TypeErorrs See the comments in this changeset for more info on why this was needed.
9c732af to
2bb1c16
Compare
anomiex
left a comment
There was a problem hiding this comment.
Seems ok and makes sense considering the stack trace of the bug this is fixing and the commit bisected to, but I'm not the most well-versed in all the details of React stuff.
Yeah, I don't like changing the argument's value either. I think your suggestion of a more localized fix makes sense. Done in 0eecb37. This is really a laser-focused fix based on the stacktrace of the unhandled exception that prevents the block from rendering, but I haven't seen any other failures due to the |
anomiex
left a comment
There was a problem hiding this comment.
This looks safer, targeting just what seems to have changed to cause the bug. 👍
| record.current = create( { | ||
| html: preserveWhiteSpace ? value : collapseWhiteSpace( value ), | ||
| html: preserveWhiteSpace | ||
| ? value |
There was a problem hiding this comment.
I tested the scenario with presrveWhiteSpace = true and it doesn't crash, so the problem seems limited to the collapseWhiteSpace call.
collapseWhiteSpace() if value is not a string
…hiteSpace()` if `value` is not a string (#56570) * (RichText)(Fix)(Workaround) Make sure value is always a string to avoid TypeErorrs See the comments in this changeset for more info on why this was needed. * Use a more localized fix that does not change the argument
…hiteSpace()` if `value` is not a string (#56570) * (RichText)(Fix)(Workaround) Make sure value is always a string to avoid TypeErorrs See the comments in this changeset for more info on why this was needed. * Use a more localized fix that does not change the argument
What?
Add a safeguard type-check that sets the
valueto''if it's not a string in theRichTextcomponent.A better solution would be to figure out why
nullis being passed there, but this seems to be a feasible temporary workaround if we don't get to the real culprit.Why?
The issue that led to this fix was found in the
Multi-Line Text Field block, provided by Jetpack. The block is completely broken in 17.1.2 and (current)trunk`.How?
By passing an empty string to the
collapseWhiteSpaceifvalueis not a string.Testing Instructions
Multi-Line Text Field;This block has encountered an error and cannot be previewed.is rendered;Multi-Line Text Fieldblock to the page and notice how it render and works correctly now.Testing Instructions for Keyboard
Screenshots or screencast