From b2ad15f306b8fe3c8dacbf1eb4c6cab89f1c7b32 Mon Sep 17 00:00:00 2001 From: karthick-murugan Date: Mon, 9 Dec 2024 16:12:29 +0530 Subject: [PATCH] keyboard capitalisation --- packages/block-library/src/paragraph/edit.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/block-library/src/paragraph/edit.js b/packages/block-library/src/paragraph/edit.js index d32b4e8d5eca0..3af1667564f3d 100644 --- a/packages/block-library/src/paragraph/edit.js +++ b/packages/block-library/src/paragraph/edit.js @@ -146,9 +146,14 @@ function ParagraphBlock( { tagName="p" { ...blockProps } value={ content } - onChange={ ( newContent ) => - setAttributes( { content: newContent } ) - } + onChange={ ( newContent ) => { + // Capitalize the first letter only if the content is empty + const updatedContent = RichText.isEmpty( content ) + ? newContent.charAt( 0 ).toUpperCase() + + newContent.slice( 1 ) + : newContent; + setAttributes( { content: updatedContent } ); + } } onMerge={ mergeBlocks } onReplace={ onReplace } onRemove={ onRemove }