From 4629722054e5ba4bdb53b777a2e6069d9085d8cf Mon Sep 17 00:00:00 2001 From: Abhishek-17H Date: Sun, 12 Jan 2025 12:40:34 +0530 Subject: [PATCH] Adding new text block via dropdown when current block is empty --- packages/volto/news/6574.feature | 1 + .../manage/BlockChooser/BlockChooserButton.jsx | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 packages/volto/news/6574.feature diff --git a/packages/volto/news/6574.feature b/packages/volto/news/6574.feature new file mode 100644 index 0000000000..14c92bf08f --- /dev/null +++ b/packages/volto/news/6574.feature @@ -0,0 +1 @@ +You can now add a text block by clicking the circled `+` icon ("Add" block button) and selecting "Text" from the pop-up menu. Previously no text block would be inserted. @Abhishek-17h \ No newline at end of file diff --git a/packages/volto/src/components/manage/BlockChooser/BlockChooserButton.jsx b/packages/volto/src/components/manage/BlockChooser/BlockChooserButton.jsx index d75055f375..54ccb41fe1 100644 --- a/packages/volto/src/components/manage/BlockChooser/BlockChooserButton.jsx +++ b/packages/volto/src/components/manage/BlockChooser/BlockChooserButton.jsx @@ -135,8 +135,16 @@ const BlockChooserButton = (props) => { onInsertBlock={ onInsertBlock ? (id, value) => { - setAddNewBlockOpened(false); - onInsertBlock(id, value); + if ( + data['@type'] === value['@type'] && + value['@type'] === 'slate' + ) { + onMutateBlock(block, { ...data, ...value }); + setAddNewBlockOpened(false); + } else { + setAddNewBlockOpened(false); + onInsertBlock(id, value); + } } : null }