From f17ce929ed5727a7e50e4e26469301901fbf0d69 Mon Sep 17 00:00:00 2001 From: Marc Thomas Date: Mon, 4 Sep 2023 14:09:53 +0100 Subject: [PATCH 1/6] chore: ensure toasts are audible upon multiple appearances --- polaris-react/src/components/Frame/components/Toast/Toast.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polaris-react/src/components/Frame/components/Toast/Toast.tsx b/polaris-react/src/components/Frame/components/Toast/Toast.tsx index 9f5e66884d4..c74f2a3e28c 100644 --- a/polaris-react/src/components/Frame/components/Toast/Toast.tsx +++ b/polaris-react/src/components/Frame/components/Toast/Toast.tsx @@ -87,7 +87,7 @@ export function Toast({ const className = classNames(styles.Toast, error && styles.error); return ( -
+
{leadingIconMarkup} From a33aab830b83d57e7f47e5267b5ee5341175f680 Mon Sep 17 00:00:00 2001 From: Marc Thomas Date: Mon, 4 Sep 2023 14:15:05 +0100 Subject: [PATCH 2/6] chore: add changeset --- .changeset/seven-oranges-fetch.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/seven-oranges-fetch.md diff --git a/.changeset/seven-oranges-fetch.md b/.changeset/seven-oranges-fetch.md new file mode 100644 index 00000000000..9ef53522eaa --- /dev/null +++ b/.changeset/seven-oranges-fetch.md @@ -0,0 +1,5 @@ +--- +'@shopify/polaris': minor +--- + +Updated the Toast component to support multiple re-renders being announced on screen readers From 05c61b9ed04e520cf3b99e41ef7809a7646fdd8c Mon Sep 17 00:00:00 2001 From: Marc Thomas Date: Wed, 13 Sep 2023 10:30:01 +0100 Subject: [PATCH 3/6] chore: render toast contents within Dialog --- polaris-react/src/components/Frame/Frame.tsx | 1 + .../components/ToastManager/ToastManager.tsx | 2 +- .../src/components/Modal/Modal.stories.tsx | 875 +++++++++--------- .../Modal/components/Dialog/Dialog.tsx | 15 + .../PolarisTestProvider.tsx | 2 + .../src/components/Toast/Toast.stories.tsx | 77 ++ polaris-react/src/utilities/frame/context.ts | 1 + 7 files changed, 552 insertions(+), 421 deletions(-) diff --git a/polaris-react/src/components/Frame/Frame.tsx b/polaris-react/src/components/Frame/Frame.tsx index 77fa377b742..0b70291d508 100644 --- a/polaris-react/src/components/Frame/Frame.tsx +++ b/polaris-react/src/components/Frame/Frame.tsx @@ -263,6 +263,7 @@ class FrameInner extends PureComponent { logo, showToast: this.showToast, hideToast: this.hideToast, + toastMessages, startLoading: this.startLoading, stopLoading: this.stopLoading, setContextualSaveBar: this.setContextualSaveBar, diff --git a/polaris-react/src/components/Frame/components/ToastManager/ToastManager.tsx b/polaris-react/src/components/Frame/components/ToastManager/ToastManager.tsx index 6cd3f20efd6..6335de39320 100644 --- a/polaris-react/src/components/Frame/components/ToastManager/ToastManager.tsx +++ b/polaris-react/src/components/Frame/components/ToastManager/ToastManager.tsx @@ -61,7 +61,7 @@ export const ToastManager = memo(function ToastManager({ }); return ( - +
{toastsMarkup} diff --git a/polaris-react/src/components/Modal/Modal.stories.tsx b/polaris-react/src/components/Modal/Modal.stories.tsx index 11f9dfee887..a5a9fdddfbf 100644 --- a/polaris-react/src/components/Modal/Modal.stories.tsx +++ b/polaris-react/src/components/Modal/Modal.stories.tsx @@ -12,6 +12,7 @@ import { Text, TextContainer, TextField, + Frame, } from '@shopify/polaris'; export default { @@ -26,31 +27,34 @@ export function Default() { const activator = ; return ( -
- +
+ - - - Use Instagram posts to share your products with millions of people. - Let shoppers buy from your store without leaving Instagram. - - - -
+ }} + secondaryActions={[ + { + content: 'Learn more', + onAction: handleChange, + }, + ]} + > + + + Use Instagram posts to share your products with millions of + people. Let shoppers buy from your store without leaving + Instagram. + + +
+
+ ); } @@ -77,45 +81,47 @@ export function WithPrimaryAction() { const activator = ; return ( -
- - - - - - You can share this discount link with your customers via email - or social media. Your discount will be automatically applied at - checkout. - - - - {}} - autoComplete="off" - connectedRight={ - - } - /> - - - - -
+ +
+ + + + + + You can share this discount link with your customers via email + or social media. Your discount will be automatically applied + at checkout. + + + + {}} + autoComplete="off" + connectedRight={ + + } + /> + + + + +
+ ); } @@ -151,56 +157,58 @@ export function WithPrimaryAndSecondaryActions() { const activator = ; return ( -
- +
+ - - - - - - - - - - - -
+ }} + secondaryActions={[ + { + content: 'Cancel', + onAction: handleClose, + }, + ]} + > + + + + + + + + + + +
+
+ ); } @@ -215,43 +223,45 @@ export function Large() { const activator = ; return ( -
- +
+ - - - {}} - > - - - - - - -
+ }} + secondaryActions={[ + { + content: 'Cancel', + onAction: toggleActive, + }, + ]} + > + + + {}} + > + + + + + +
+
+ ); } @@ -266,43 +276,45 @@ export function Small() { const activator = ; return ( -
- +
+ - - - {}} - > - - - - - - -
+ }} + secondaryActions={[ + { + content: 'Cancel', + onAction: toggleActive, + }, + ]} + > + + + {}} + > + + + + + +
+
+ ); } @@ -314,32 +326,35 @@ export function WithoutATitle() { const activator = ; return ( -
- +
+ - - - Use Instagram posts to share your products with millions of people. - Let shoppers buy from your store without leaving Instagram. - - - -
+ }} + secondaryActions={[ + { + content: 'Learn more', + onAction: handleChange, + }, + ]} + > + + + Use Instagram posts to share your products with millions of + people. Let shoppers buy from your store without leaving + Instagram. + + +
+
+ ); } @@ -356,23 +371,25 @@ export function WithScrollListener() { const activator = ; return ( -
- - {Array.from({length: 50}, (_, index) => ( - - - Item #{index} - - - ))} - -
+ +
+ + {Array.from({length: 50}, (_, index) => ( + + + Item #{index} + + + ))} + +
+ ); } @@ -394,32 +411,35 @@ export function WithActivatorRef() { ); return ( -
- {activator} - +
+ {activator} + - - - Use Instagram posts to share your products with millions of people. - Let shoppers buy from your store without leaving Instagram. - - - -
+ }} + secondaryActions={[ + { + content: 'Learn more', + onAction: handleClose, + }, + ]} + > + + + Use Instagram posts to share your products with millions of + people. Let shoppers buy from your store without leaving + Instagram. + + +
+
+ ); } @@ -436,144 +456,152 @@ export function WithoutAnActivatorProp() { }, []); return ( -
-
- -
- +
+
+ +
+ - - - Use Instagram posts to share your products with millions of people. - Let shoppers buy from your store without leaving Instagram. - - - -
+ }} + secondaryActions={[ + { + content: 'Learn more', + onAction: handleClose, + }, + ]} + > + + + Use Instagram posts to share your products with millions of + people. Let shoppers buy from your store without leaving + Instagram. + + +
+
+ ); } export function WithLongContent() { return ( - {}} - primaryAction={{content: 'Save'}} - > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + {}} + primaryAction={{content: 'Save'}} + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); } export function WithLongContentNoScroll() { return ( - {}} - noScroll - primaryAction={{content: 'Save'}} - > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ); -} - -export function EmbeddedIframe() { - return ( -
+ {}} noScroll primaryAction={{content: 'Save'}} - src={`data:text/html;charset=utf-8, + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} + +export function EmbeddedIframe() { + return ( + +
+ {}} + noScroll + primaryAction={{content: 'Save'}} + src={`data:text/html;charset=utf-8,