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 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/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} 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..0b804eedffe 100644 --- a/polaris-react/src/components/Modal/Modal.stories.tsx +++ b/polaris-react/src/components/Modal/Modal.stories.tsx @@ -12,6 +12,8 @@ import { Text, TextContainer, TextField, + Frame, + FrameContext, } from '@shopify/polaris'; export default { @@ -26,31 +28,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 +82,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 +158,58 @@ export function WithPrimaryAndSecondaryActions() { const activator = ; return ( -
- +
+ - - - - - - - - - - - -
+ }} + secondaryActions={[ + { + content: 'Cancel', + onAction: handleClose, + }, + ]} + > + + + + + + + + + + +
+
+ ); } @@ -215,43 +224,45 @@ export function Large() { const activator = ; return ( -
- +
+ - - - {}} - > - - - - - - -
+ }} + secondaryActions={[ + { + content: 'Cancel', + onAction: toggleActive, + }, + ]} + > + + + {}} + > + + + + + +
+
+ ); } @@ -266,43 +277,45 @@ export function Small() { const activator = ; return ( -
- +
+ - - - {}} - > - - - - - - -
+ }} + secondaryActions={[ + { + content: 'Cancel', + onAction: toggleActive, + }, + ]} + > + + + {}} + > + + + + + +
+
+ ); } @@ -314,32 +327,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 +372,25 @@ export function WithScrollListener() { const activator = ; return ( -
- - {Array.from({length: 50}, (_, index) => ( - - - Item #{index} - - - ))} - -
+ +
+ + {Array.from({length: 50}, (_, index) => ( + + + Item #{index} + + + ))} + +
+ ); } @@ -394,32 +412,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 +457,162 @@ 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, + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} + +const context = { + logo: undefined, + showToast: () => {}, + hideToast: () => {}, + toastMessages: [], + startLoading: () => {}, + stopLoading: () => {}, + setContextualSaveBar: () => {}, + removeContextualSaveBar: () => {}, +}; +export function EmbeddedIframe() { + return ( + +
+ {}} + noScroll + primaryAction={{content: 'Save'}} + src={`data:text/html;charset=utf-8,