From da810b5faa924201a96452da3e24400366a03372 Mon Sep 17 00:00:00 2001 From: Sabrina Bongiovanni Date: Thu, 28 Mar 2024 16:32:56 +0100 Subject: [PATCH] fix: added redraft to convert into string for aria-label and changed label structure --- .../Blocks/IconBlocks/Block/ViewBlock.jsx | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/components/ItaliaTheme/Blocks/IconBlocks/Block/ViewBlock.jsx b/src/components/ItaliaTheme/Blocks/IconBlocks/Block/ViewBlock.jsx index f4e49e6ff..1273dfa41 100644 --- a/src/components/ItaliaTheme/Blocks/IconBlocks/Block/ViewBlock.jsx +++ b/src/components/ItaliaTheme/Blocks/IconBlocks/Block/ViewBlock.jsx @@ -27,16 +27,19 @@ const messages = defineMessages({ * @extends Component */ const ViewBlock = ({ data, isOpen, toggle, id, index }) => { - console.log(config.settings.richtextViewSettings); - console.log(data); - const rawStringRenderer = { blocks: { - unstyled: (children) => children.join('m'), + unstyled: (children) => { + const text = children.map((child) => child[1]).join(''); // Join the text elements + return text.trim(); // Remove leading/trailing whitespace + }, }, }; - console.log(redraft(data.title, rawStringRenderer)); + const cardTitle = redraft(data.title, rawStringRenderer, { + cleanup: false, + }); + const intl = useIntl(); return ( { tag={UniversalLink} href={data.href ?? '#'} text={data.linkMoreTitle || intl.formatMessage(messages.vedi)} - aria-label={ - data.linkMoreTitle - ? data.linkMoreTitle - : intl.formatMessage(messages.vedi) + ' ' + data.title - } + aria-label={`${ + data.linkMoreTitle || intl.formatMessage(messages.vedi) + } ${data.title ? cardTitle[0] : ''}`} /> )}