From 9784a36229a48af3ccbe93c244c9f506bd15f3fb Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Mon, 27 Nov 2023 18:09:08 -0600 Subject: [PATCH] (RichText)(Workaround)(17.1.x) Fallback to a string arg in `collapseWhiteSpace()` 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 --- packages/rich-text/src/component/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/rich-text/src/component/index.js b/packages/rich-text/src/component/index.js index 87e57e49e4333e..0e9291b7a5e03d 100644 --- a/packages/rich-text/src/component/index.js +++ b/packages/rich-text/src/component/index.js @@ -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 );