From 417f6eacad3782e6d1729f130d88a596afcaae51 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Fri, 24 May 2024 15:54:18 +0400 Subject: [PATCH] More block: Fix React warning when adding custom text (#61936) Co-authored-by: Mamaduka Co-authored-by: ellatrix --- packages/block-library/src/more/block.json | 3 ++- packages/block-library/src/more/edit.js | 3 +-- test/integration/fixtures/blocks/core__more.json | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/block-library/src/more/block.json b/packages/block-library/src/more/block.json index b071f6ba5d7ef..d1153ca4f1689 100644 --- a/packages/block-library/src/more/block.json +++ b/packages/block-library/src/more/block.json @@ -9,7 +9,8 @@ "textdomain": "default", "attributes": { "customText": { - "type": "string" + "type": "string", + "default": "" }, "noTeaser": { "type": "boolean", diff --git a/packages/block-library/src/more/edit.js b/packages/block-library/src/more/edit.js index 7757af5e96ba1..bcad7ec1b8366 100644 --- a/packages/block-library/src/more/edit.js +++ b/packages/block-library/src/more/edit.js @@ -16,8 +16,7 @@ export default function MoreEdit( { } ) { const onChangeInput = ( event ) => { setAttributes( { - customText: - event.target.value !== '' ? event.target.value : undefined, + customText: event.target.value, } ); }; diff --git a/test/integration/fixtures/blocks/core__more.json b/test/integration/fixtures/blocks/core__more.json index 29ec11579a2d9..f9f34aecd1f20 100644 --- a/test/integration/fixtures/blocks/core__more.json +++ b/test/integration/fixtures/blocks/core__more.json @@ -3,6 +3,7 @@ "name": "core/more", "isValid": true, "attributes": { + "customText": "", "noTeaser": false }, "innerBlocks": []