Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Raw html to fix notice encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Mar 10, 2023
1 parent 3175eb3 commit 0b91d29
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
10 changes: 5 additions & 5 deletions assets/js/base/components/notice-banner/stories/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand All @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions assets/js/base/components/notice-banner/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -95,7 +95,9 @@ const StoreNotices = ( {
key={ notice.id + '-' + notice.context }
{ ...notice }
>
{ sanitizeHTML( decodeEntities( notice.content ) ) }
<RawHTML>
{ sanitizeHTML( decodeEntities( notice.content ) ) }
</RawHTML>
</StoreNotice>
) ) }
{ Object.entries( dismissibleNoticeGroups ).map(
Expand Down Expand Up @@ -134,7 +136,7 @@ const StoreNotices = ( {
};
return uniqueNotices.length === 1 ? (
<StoreNotice { ...noticeProps }>
{ noticeGroup[ 0 ].content }
<RawHTML>{ noticeGroup[ 0 ].content }</RawHTML>
</StoreNotice>
) : (
<StoreNotice
Expand All @@ -153,7 +155,7 @@ const StoreNotices = ( {
<li
key={ notice.id + '-' + notice.context }
>
{ notice.content }
<RawHTML>{ notice.content }</RawHTML>
</li>
) ) }
</ul>
Expand Down

0 comments on commit 0b91d29

Please sign in to comment.