Skip to content

Commit

Permalink
(RichText)(Workaround)(17.1.x) Fallback to a string arg in `collapseW…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
fullofcaffeine committed Nov 28, 2023
1 parent a1f8076 commit 9784a36
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/rich-text/src/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export function useRichText( {
function setRecordFromProps() {
_value.current = value;
record.current = create( {
html: preserveWhiteSpace ? value : collapseWhiteSpace( value ),
html: preserveWhiteSpace
? value
: collapseWhiteSpace( typeof value === 'string' ? value : '' ),
} );
if ( disableFormats ) {
record.current.formats = Array( value.length );
Expand Down

0 comments on commit 9784a36

Please sign in to comment.