From 0b91d298ef342bb164bcb575a537d0c903c29ca5 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 10 Mar 2023 17:05:10 +0000 Subject: [PATCH] Raw html to fix notice encoding --- .../js/base/components/notice-banner/stories/index.tsx | 10 +++++----- assets/js/base/components/notice-banner/style.scss | 8 ++++++++ .../store-notices-container/store-notices.tsx | 10 ++++++---- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/assets/js/base/components/notice-banner/stories/index.tsx b/assets/js/base/components/notice-banner/stories/index.tsx index fcb4adab3d3..202a0088e5e 100644 --- a/assets/js/base/components/notice-banner/stories/index.tsx +++ b/assets/js/base/components/notice-banner/stories/index.tsx @@ -22,11 +22,6 @@ export default { control: 'boolean', description: 'Determines whether the notice can be dismissed.', }, - children: { - description: - 'The content of the notice; either text or a React node such as a list of errors.', - control: 'text', - }, summary: { description: 'Optional summary text shown above notice content, used when several notices are listed together.', @@ -47,6 +42,11 @@ export default { description: 'Determines the level of politeness for the notice for assistive technology.', }, + children: { + description: + 'The content of the notice; either text or a React node such as a list of errors.', + disable: true, + }, onRemove: { description: 'Function called when dismissing the notice.', disable: true, diff --git a/assets/js/base/components/notice-banner/style.scss b/assets/js/base/components/notice-banner/style.scss index 517dc8acf24..e5a21caaf93 100644 --- a/assets/js/base/components/notice-banner/style.scss +++ b/assets/js/base/components/notice-banner/style.scss @@ -24,6 +24,14 @@ align-self: center; white-space: normal; + > div *:first-child { + margin-top: 0; + } + + > div *:last-child { + margin-bottom: 0; + } + &:last-child { padding-right: 0; } diff --git a/packages/checkout/components/store-notices-container/store-notices.tsx b/packages/checkout/components/store-notices-container/store-notices.tsx index c13aa8ddd77..8680fd7ae95 100644 --- a/packages/checkout/components/store-notices-container/store-notices.tsx +++ b/packages/checkout/components/store-notices-container/store-notices.tsx @@ -3,7 +3,7 @@ */ import { __ } from '@wordpress/i18n'; import classnames from 'classnames'; -import { useRef, useEffect } from '@wordpress/element'; +import { useRef, useEffect, RawHTML } from '@wordpress/element'; import { sanitizeHTML } from '@woocommerce/utils'; import { useDispatch } from '@wordpress/data'; import { usePrevious } from '@woocommerce/base-hooks'; @@ -95,7 +95,9 @@ const StoreNotices = ( { key={ notice.id + '-' + notice.context } { ...notice } > - { sanitizeHTML( decodeEntities( notice.content ) ) } + + { sanitizeHTML( decodeEntities( notice.content ) ) } + ) ) } { Object.entries( dismissibleNoticeGroups ).map( @@ -134,7 +136,7 @@ const StoreNotices = ( { }; return uniqueNotices.length === 1 ? ( - { noticeGroup[ 0 ].content } + { noticeGroup[ 0 ].content } ) : ( - { notice.content } + { notice.content } ) ) }