Skip to content

Commit

Permalink
fix: added redraft to convert into string for aria-label and changed …
Browse files Browse the repository at this point in the history
…label structure
  • Loading branch information
sabrina-bongiovanni committed Mar 28, 2024
1 parent 9ce3d68 commit da810b5
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/components/ItaliaTheme/Blocks/IconBlocks/Block/ViewBlock.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Card
Expand Down Expand Up @@ -76,11 +79,9 @@ const ViewBlock = ({ data, isOpen, toggle, id, index }) => {
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] : ''}`}
/>
)}
</CardBody>
Expand Down

0 comments on commit da810b5

Please sign in to comment.