Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Conversation

mrcthms
Copy link
Contributor

@mrcthms mrcthms commented Sep 12, 2023

WHY are these changes introduced?

Fixes https://github.com/Shopify/web/issues/99380

We currently have a bug in the Toast component whereby if a Toast is shown to a merchant multiple times, the screen reader will only announce the Toast for the first appearance. By also adding an aria-live="assertive" attribute inside the Toast itself, we can now ensure that Toasts get announced for every subsequent appearance on screen.

There is also a bug where if a Toast is rendered when a Modal is open on the screen, then the Toast will not get read out by the screen reader. This is due to the Dialog component within the Modal having the aria-modal attribute, which effectively instructs the browser to ignore all content that sits outside that element. This means that our aria-live region containing the Toasts is inaccessible to the screen reader.

In order to solve this, we now will inject the content of the Toast(s) into the Dialog itself, inside a designated aria-live region, so that the screen reader can announce the content of the Toasts, but because the Toast content is wrapped in a visually hidden Text component, nothing extra appears on screen.

We also extend the context provided by the Frame to include the array of currently active toastMessages, as this is needed to render the contents within the Dialog. We also now export the useFrame hook as the SettingsDialog within Shopify/web uses a custom dialog component, so we will need to replicate the solution there, which utilises the useFrame hook.

Spinstance: https://admin.web.settings-dialog-toast.marc-thomas.eu.spin.dev/store/shop1/settings/general

How to 🎩

🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines

Toast announcing every time

  1. Navigate to https://5d559397bae39100201eedc1-oivciscfnt.chromatic.com/?path=/story/all-components-toast--default
  2. Activate VoiceOver
  3. Repeatedly show the Toast
  4. Confirm that the Toast gets read out by VoiceOver every time it gets shown

Toast announcing inside Modal

  1. Navigate to https://5d559397bae39100201eedc1-oivciscfnt.chromatic.com/?path=/story/all-components-toast--inside-modal
  2. Activate VoiceOver
  3. Show the toast messages
  4. Confirm that the Toast messages get read out by VoiceOver each time they are shown

🎩 checklist

@mrcthms
Copy link
Contributor Author

mrcthms commented Sep 12, 2023

/snapit

@github-actions
Copy link
Contributor

🫰✨ Thanks @mrcthms! Your snapshot has been published to npm.

Test the snapshot by updating your package.json with the newly published version:

yarn add @shopify/polaris@0.0.0-snapshot-release-20230912103942

@mrcthms mrcthms changed the title [Toast] Improve screen reader experience [Toast|Dialog] Improve screen reader experience for Toasts and Toasts within Dialogs Sep 13, 2023
@mrcthms
Copy link
Contributor Author

mrcthms commented Sep 13, 2023

/snapit

@mrcthms
Copy link
Contributor Author

mrcthms commented Sep 13, 2023

/snapit

@github-actions
Copy link
Contributor

🫰✨ Thanks @mrcthms! Your snapshot has been published to npm.

Test the snapshot by updating your package.json with the newly published version:

yarn add @shopify/polaris@0.0.0-snapshot-release-20230913100027

@mrcthms
Copy link
Contributor Author

mrcthms commented Sep 13, 2023

/snapit

@github-actions
Copy link
Contributor

🫰✨ Thanks @mrcthms! Your snapshot has been published to npm.

Test the snapshot by updating your package.json with the newly published version:

yarn add @shopify/polaris@0.0.0-snapshot-release-20230913102018

@mrcthms mrcthms merged commit 87f559c into main Sep 13, 2023
@mrcthms mrcthms deleted the mrcthms-toast-aria branch September 13, 2023 14:25
mrcthms pushed a commit that referenced this pull request Sep 14, 2023
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @shopify/polaris@11.18.0

### Minor Changes

- [#10429](#10429)
[`2e65a7e98`](2e65a7e)
Thanks [@mrcthms](https://github.com/mrcthms)! - Fixed `Filters` pinned
filter pill not remaining when applied values are cleared


- [#10394](#10394)
[`b7f25f07f`](b7f25f0)
Thanks [@mrcthms](https://github.com/mrcthms)! - Added support for
disabling 1Password integration in `TextField`


- [#10406](#10406)
[`87f559ca1`](87f559c)
Thanks [@mrcthms](https://github.com/mrcthms)! - Updated the Toast
component to support multiple re-renders being announced on screen
readers

### Patch Changes

- [#10428](#10428)
[`d35d55e5b`](d35d55e)
Thanks [@mrcthms](https://github.com/mrcthms)! - Fixed layout shift in
`IndexFilters` when switching modes

- Updated dependencies
\[[`26ab8ce7d`](26ab8ce),
[`7514dd1a3`](7514dd1),
[`16c61668a`](16c6166)]:
    -   @shopify/polaris-tokens@7.8.0

## @shopify/polaris-tokens@7.8.0

### Minor Changes

- [#10432](#10432)
[`26ab8ce7d`](26ab8ce)
Thanks [@lgriffee](https://github.com/lgriffee)! - Added public
primitive `border-radius` token scale


- [#10448](#10448)
[`7514dd1a3`](7514dd1)
Thanks [@lgriffee](https://github.com/lgriffee)! - Added public
primitive `space` token scale


- [#10418](#10418)
[`16c61668a`](16c6166)
Thanks [@lgriffee](https://github.com/lgriffee)! - Added private
primitive `size` token scale

## @shopify/polaris-migrator@0.22.3

### Patch Changes

- Updated dependencies
\[[`26ab8ce7d`](26ab8ce),
[`7514dd1a3`](7514dd1),
[`16c61668a`](16c6166)]:
    -   @shopify/polaris-tokens@7.8.0
    -   @shopify/stylelint-polaris@14.0.3

## @shopify/stylelint-polaris@14.0.3

### Patch Changes

- Updated dependencies
\[[`26ab8ce7d`](26ab8ce),
[`7514dd1a3`](7514dd1),
[`16c61668a`](16c6166)]:
    -   @shopify/polaris-tokens@7.8.0

## polaris.shopify.com@0.57.6

### Patch Changes

- Updated dependencies
\[[`2e65a7e98`](2e65a7e),
[`b7f25f07f`](b7f25f0),
[`26ab8ce7d`](26ab8ce),
[`d35d55e5b`](d35d55e),
[`7514dd1a3`](7514dd1),
[`16c61668a`](16c6166),
[`87f559ca1`](87f559c)]:
    -   @shopify/polaris@11.18.0
    -   @shopify/polaris-tokens@7.8.0

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
sophschneider added a commit that referenced this pull request Sep 25, 2023
sophschneider added a commit that referenced this pull request Sep 26, 2023
AnnaCheba pushed a commit to AnnaCheba/polaris that referenced this pull request Apr 22, 2024
… within Dialogs (Shopify#10406)

<!--
  ☝️How to write a good PR title:
- Prefix it with [ComponentName] (if applicable), for example: [Button]
  - Start with a verb, for example: Add, Delete, Improve, Fix…
  - Give as much context as necessary and as little as possible
  - Prefix it with [WIP] while it’s a work in progress
-->

### WHY are these changes introduced?

Fixes Shopify/web#99380

We currently have a bug in the Toast component whereby if a Toast is
shown to a merchant multiple times, the screen reader will only announce
the Toast for the first appearance. By also adding an`
aria-live="assertive"` attribute inside the Toast itself, we can now
ensure that Toasts get announced for every subsequent appearance on
screen.

There is also a bug where if a Toast is rendered when a Modal is open on
the screen, then the Toast will not get read out by the screen reader.
This is due to the Dialog component within the Modal having the
`aria-modal` attribute, which effectively instructs the browser to
ignore all content that sits outside that element. This means that our
aria-live region containing the Toasts is inaccessible to the screen
reader.

In order to solve this, we now will inject the content of the Toast(s)
into the Dialog itself, inside a designated aria-live region, so that
the screen reader can announce the content of the Toasts, but because
the Toast content is wrapped in a visually hidden Text component,
nothing extra appears on screen.

We also extend the `context` provided by the Frame to include the array
of currently active toastMessages, as this is needed to render the
contents within the Dialog. We also now export the `useFrame` hook as
the SettingsDialog within Shopify/web uses a custom dialog component, so
we will need to replicate the solution there, which utilises the
`useFrame` hook.

Spinstance:
https://admin.web.settings-dialog-toast.marc-thomas.eu.spin.dev/store/shop1/settings/general


<!-- ℹ️ Delete the following for small / trivial changes -->

### How to 🎩

🖥 [Local development
instructions](https://github.com/Shopify/polaris/blob/main/README.md#local-development)
🗒 [General tophatting
guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md)
📄 [Changelog
guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog)

**Toast announcing every time**

1. Navigate to
https://5d559397bae39100201eedc1-oivciscfnt.chromatic.com/?path=/story/all-components-toast--default
2. Activate VoiceOver
3. Repeatedly show the Toast
4. Confirm that the Toast gets read out by VoiceOver every time it gets
shown

**Toast announcing inside Modal**

1. Navigate to
https://5d559397bae39100201eedc1-oivciscfnt.chromatic.com/?path=/story/all-components-toast--inside-modal
2. Activate VoiceOver
3. Show the toast messages
4. Confirm that the Toast messages get read out by VoiceOver each time
they are shown

### 🎩 checklist

- [x] Tested on
[mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing)
- [x] Tested on [multiple
browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers)
- [x] Tested for
[accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md)
- [x] Updated the component's `README.md` with documentation changes
- [x] [Tophatted
documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md)
changes in the style guide
ascherkus pushed a commit to ascherkus/polaris that referenced this pull request Feb 19, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @shopify/polaris@11.18.0

### Minor Changes

- [Shopify#10429](Shopify#10429)
[`2e65a7e98`](Shopify@78e3c64)
Thanks [@mrcthms](https://github.com/mrcthms)! - Fixed `Filters` pinned
filter pill not remaining when applied values are cleared


- [Shopify#10394](Shopify#10394)
[`b7f25f07f`](Shopify@11a5ec4)
Thanks [@mrcthms](https://github.com/mrcthms)! - Added support for
disabling 1Password integration in `TextField`


- [Shopify#10406](Shopify#10406)
[`87f559ca1`](Shopify@87ef9b6)
Thanks [@mrcthms](https://github.com/mrcthms)! - Updated the Toast
component to support multiple re-renders being announced on screen
readers

### Patch Changes

- [Shopify#10428](Shopify#10428)
[`d35d55e5b`](Shopify@ded82d4)
Thanks [@mrcthms](https://github.com/mrcthms)! - Fixed layout shift in
`IndexFilters` when switching modes

- Updated dependencies
\[[`26ab8ce7d`](Shopify@2638248),
[`7514dd1a3`](Shopify@beb664a),
[`16c61668a`](Shopify@54284eb)]:
    -   @shopify/polaris-tokens@7.8.0

## @shopify/polaris-tokens@7.8.0

### Minor Changes

- [Shopify#10432](Shopify#10432)
[`26ab8ce7d`](Shopify@2638248)
Thanks [@lgriffee](https://github.com/lgriffee)! - Added public
primitive `border-radius` token scale


- [Shopify#10448](Shopify#10448)
[`7514dd1a3`](Shopify@beb664a)
Thanks [@lgriffee](https://github.com/lgriffee)! - Added public
primitive `space` token scale


- [Shopify#10418](Shopify#10418)
[`16c61668a`](Shopify@54284eb)
Thanks [@lgriffee](https://github.com/lgriffee)! - Added private
primitive `size` token scale

## @shopify/polaris-migrator@0.22.3

### Patch Changes

- Updated dependencies
\[[`26ab8ce7d`](Shopify@2638248),
[`7514dd1a3`](Shopify@beb664a),
[`16c61668a`](Shopify@54284eb)]:
    -   @shopify/polaris-tokens@7.8.0
    -   @shopify/stylelint-polaris@14.0.3

## @shopify/stylelint-polaris@14.0.3

### Patch Changes

- Updated dependencies
\[[`26ab8ce7d`](Shopify@2638248),
[`7514dd1a3`](Shopify@beb664a),
[`16c61668a`](Shopify@54284eb)]:
    -   @shopify/polaris-tokens@7.8.0

## polaris.shopify.com@0.57.6

### Patch Changes

- Updated dependencies
\[[`2e65a7e98`](Shopify@78e3c64),
[`b7f25f07f`](Shopify@11a5ec4),
[`26ab8ce7d`](Shopify@2638248),
[`d35d55e5b`](Shopify@ded82d4),
[`7514dd1a3`](Shopify@beb664a),
[`16c61668a`](Shopify@54284eb),
[`87f559ca1`](Shopify@87ef9b6)]:
    -   @shopify/polaris@11.18.0
    -   @shopify/polaris-tokens@7.8.0

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
ascherkus pushed a commit to ascherkus/polaris that referenced this pull request Feb 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants