Skip to content

docs(alert-dialog): updated docs #5371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Apr 16, 2025
Merged

docs(alert-dialog): updated docs #5371

merged 20 commits into from
Apr 16, 2025

Conversation

nikkimk
Copy link
Contributor

@nikkimk nikkimk commented Apr 11, 2025

Description

Improving the accessibility documentation of components.

Related issue(s)

  • SWC-356

Motivation and context

Documentation should provide more information and examples that demonstrate how to use the components accessibly.

How has this been tested?

Review alert dialog docs

  • Do the docs examples give enough context to test for accessibility?

  • Do the docs examples and text provide information on how to use the component accessibly?

  • If the component is to be used in the context of another component, do the examples include how that component is used accessibly in that context?

  • Are the docs headings logical and consistent across these components? You can use the WAVE browser extension's Structure tab to review heading structure.

  • Did it pass in Desktop?

  • Did it pass in Mobile?

  • Did it pass in iPad?

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Checklist

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • If my change required a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices

Best practices

This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against main.

Copy link

changeset-bot bot commented Apr 11, 2025

⚠️ No Changeset found

Latest commit: 1294b52

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@nikkimk nikkimk changed the title docs(alert-dialog): updated dacs docs(alert-dialog): updated docs Apr 11, 2025
Copy link

Branch preview

Review the following VRT differences

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

Copy link

Tachometer results

Currently, no packages are changed by this PR...

@nikkimk nikkimk marked this pull request as ready for review April 11, 2025 21:04
@nikkimk nikkimk requested a review from a team as a code owner April 11, 2025 21:04
- <kbd>Space</kbd>/<kbd>Enter</kbd>: Activate the focused button
- <kbd>Esc</kbd>: Close the dialog
- Maintains proper focus management when opened and closed
- Uses ARIA roles and attributes appropriately:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should our examples have role defined based on this guidance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caseyisonit IMHO this should be part of what the component does for the consumer, rather than the onus be on the consumer. Also, I'm interested in having a11y auditors confirm that modal alerts are alertdialog because they interrupt user action where alert roles do not.

This is the default variant for alert dialogs. Use a confirmation variant for asking a user to confirm a choice.
- A heading, using `slot="heading"`, that describes the purpose of the dialog
- Content, using the default slot, that provides additional context
- Action buttons, using `slot="button"`, that allow users to respond
Copy link
Contributor

@caseyisonit caseyisonit Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Action buttons, using `slot="button"`, that allow users to respond
- **Action Button(s):**
- Use `slot="button"` to render your action button(s) that allow users to respond
- An alert dialog must have one primary action button with the option to include a secondary action and/or a cancel action.
- Non-primary action buttons should be `variant="secondary"` and `treatment: "outline"`.
- The three buttons should be rendered in the DOM in the following order:
- **Cancel action:** Offers an option to go back and cancel the action.
- **Secondary action:** Offers a secondary action. e.g. "Remind me later"
- **Primary action:** The first (right-most) button communicates what the button will do if selected, or to acknowledge and dismiss the dialog. Check [variants](#variants) for the correct primary button styling.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I'm wondering if having 3 buttons in the dialog is the right approach. Would you mind checking in with Nate Baldwin about this? I believe he's working on a more comprehensive dialog RFC that addresses a lot of the related concerns. It might offer some useful guidance and help us align better with the direction he's setting.

</sp-tab-panel>
</sp-tabs>

### Behaviors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets add a behavior section that should the alert dialog in an overlay with the correct accessibility set up. we can make a follow up ticket to add it to storybook and clean up the button spacing issue

@@ -154,7 +199,6 @@ Destructive alert dialogs are for when a user needs to confirm an action that wi
</sp-button>
<sp-button
slot="button"
id="confirmButton"
variant="negative"
treatment="fill"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
treatment="fill"
treatment="outline"

aligning to the design specs

@nikkimk nikkimk requested a review from caseyisonit April 16, 2025 13:25
This is the default variant for alert dialogs. Use a confirmation variant for asking a user to confirm a choice.
- A heading, using `slot="heading"`, that describes the purpose of the dialog
- Content, using the default slot, that provides additional context
- Action buttons, using `slot="button"`, that allow users to respond
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I'm wondering if having 3 buttons in the dialog is the right approach. Would you mind checking in with Nate Baldwin about this? I believe he's working on a more comprehensive dialog RFC that addresses a lot of the related concerns. It might offer some useful guidance and help us align better with the direction he's setting.

@nikkimk
Copy link
Contributor Author

nikkimk commented Apr 16, 2025

Hey, I'm wondering if having 3 buttons in the dialog is the right approach. Would you mind checking in with Nate Baldwin about this? I believe he's working on a more comprehensive dialog RFC that addresses a lot of the related concerns. It might offer some useful guidance and help us align better with the direction he's setting.

@Rajdeepc We (@caseyisonit and me) pulled it directly from the design guidelines.

@nikkimk nikkimk requested a review from Rajdeepc April 16, 2025 13:45
@nikkimk
Copy link
Contributor Author

nikkimk commented Apr 16, 2025

@Rajdeepc and @caseyisonit PTAL

I added a link to reference design docs on variants and button options, to address Rajdeep's feedback.

@Rajdeepc
Copy link
Contributor

Rajdeepc commented Apr 16, 2025

Hey, I'm wondering if having 3 buttons in the dialog is the right approach. Would you mind checking in with Nate Baldwin about this? I believe he's working on a more comprehensive dialog RFC that addresses a lot of the related concerns. It might offer some useful guidance and help us align better with the direction he's setting.

@Rajdeepc We (@caseyisonit and me) pulled it directly from the design guidelines.

I have a follow up question. If there are 3 buttons in a frame how the focus trap should work? Should the immediate focus goes to the primary call to action or to the first button element in the DOM? According to me it should go to the first primary call to action but we have a different implementation in our storybook.
Our storybook: https://opensource.adobe.com/spectrum-web-components/storybook/index.html?path=/story/alert-dialog--secondary

@nikkimk
Copy link
Contributor Author

nikkimk commented Apr 16, 2025

Hey, I'm wondering if having 3 buttons in the dialog is the right approach. Would you mind checking in with Nate Baldwin about this? I believe he's working on a more comprehensive dialog RFC that addresses a lot of the related concerns. It might offer some useful guidance and help us align better with the direction he's setting.

@Rajdeepc We (@caseyisonit and me) pulled it directly from the design guidelines.

I have a follow up question. If there are 3 buttons in a frame how the focus trap should work? Should the immediate focus goes to the primary call to action or to the first button element in the DOM? According to me it should go to the first primary call to action but we have a different implementation in our storybook. Our storybook: https://opensource.adobe.com/spectrum-web-components/storybook/index.html?path=/story/alert-dialog--secondary

I can definitely ask when this component gets audited.

As a reminder, the scope of this PR is to document the component as-is, so that the auditors can review our current implementation and submit issues, so this shouldn't hold back the docs.

Copy link
Contributor

@Rajdeepc Rajdeepc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Information alert dialogs communicate important information that a user needs to acknowledge. Before using this kind of alert dialog, make sure it’s the appropriate communication channel for the message instead of a toast or a more lightweight messaging option.
Use `slot="button"` to render your action button(s) that allow users to respond

- An alert dialog must have one primary action button (with `variant="secondary"`) with the option to include a secondary action and/or a cancel action.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct for the primary button to have variant="secondary"?

Non-primary action buttons should be variant="secondary" and treatment: "outline".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, @cdransf! Pushing a correction.

Use `slot="button"` to render your action button(s) that allow users to respond

- An alert dialog must have one primary action button (with `variant="primary"`) with the option to include a secondary action and/or a cancel action.
- Non-primary action buttons should be `variant="secondary"` and `treatment: "outline"`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be treatment="outline"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

- The three buttons should be rendered in the DOM in the following order:
- **Cancel action:** Offers an option to go back and cancel the action.
- **Secondary action:** Offers a secondary action. e.g. "Remind me later"
- **Primary action:** The first (right-most) button communicates what the button will do if selected, or to acknowledge and dismiss the dialog. Check [variants](#variants) for the correct primary button styling. See also the (Alert Dialog design options)[https://spectrum.adobe.com/page/alert-dialog/#Options].

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this link syntax should be swapped.

[Alert Dialog design options](https://spectrum.adobe.com/page/alert-dialog/)


#### Context

An alert dialog should be placed inside a model overaly:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be modal overlay

Comment on lines 288 to 296
### Accessibility

When implementing an alert dialog:

- Use concise, meaningful dialog title that clearly states the purpose
- Use semantic heading elements (`<h2>`) for the dialog title
- Ensure button labels clearly indicate the action they will perform
- Provide clear, concise content that explains the situation and required actions
- Consider the appropriate variant based on the message's importance and urgency

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this section here. Should we add any suggestions on using aria-labelledby or aria-describedby for the heading and description of the AlertDialog and maybe show some of those in the code highlights above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @aramos-adobe!

@nikkimk nikkimk merged commit 4a457ed into main Apr 16, 2025
24 checks passed
@nikkimk nikkimk deleted the nikkimk/alert-dialog-docs branch April 16, 2025 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants