{"id":308,"date":"2018-12-10T16:04:35","date_gmt":"2018-12-10T16:04:35","guid":{"rendered":"https:\/\/pressbooks.library.ryerson.ca\/wafd\/?post_type=chapter&#038;p=308"},"modified":"2022-12-16T18:29:59","modified_gmt":"2022-12-16T18:29:59","slug":"wai-aria-alert-and-message-dialogs","status":"publish","type":"chapter","link":"https:\/\/pressbooks.library.torontomu.ca\/wafd\/chapter\/wai-aria-alert-and-message-dialogs\/","title":{"raw":"WAI-ARIA Alert and Message Dialogs","rendered":"WAI-ARIA Alert and Message Dialogs"},"content":{"raw":"Providing feedback after a user completes an action is a critical accessibility feature. Feedback can be an error message when something has gone wrong. Additionally, it can\u00a0 be a confirmation or warning, after which a user has to make a decision before proceeding. Or, it could be completion feedback that is presented after a particular action has occurred to indicate it was successful.\r\n\r\nThe latter is often overlooked by developers. However, for people using a screen reader, notification that an action was successful can be as important as providing error messages. When completion feedback is provided, screen reader users do not need to search through the content of the screen to be sure the action they just completed was successful \u2014 the process\u00a0 can be quite time-consuming.\r\n\r\nIn each type of feedback, it is critical that messages be easy to access. The best strategy for making feedback accessible is to use the WAI-ARIA alert or alert-dialog roles. These are both types of live regions. When the content of the container element with <code>role=\"alert\"<\/code> changes, the content that appears is automatically read aloud by screen readers. A WAI-ARIA alert has an implicit <code>aria-live=\"assertive\"<\/code> and <code>aria-atomic=\"true\"<\/code> (to be covered in more detail in the section on live regions). This means that, when the message appears, it will interrupt whatever the screen reader is in the middle of reading, and the entire content of the element will be read, as opposed to just the new content added (i.e., <code>aria-atomic=\"false\"<\/code>).\r\n<div style=\"margin: 1em 0; padding: 1em; border: 1px solid #ddd; border-left: 10px solid #b9f;\"><strong>Try This:<\/strong> In the following example of a WAI-ARIA alert, start ChromeVox, then press the \u201cSay Something\u201d button to hear how ChromeVox handles the message that appears. Examine the script and HTML below to see how it was done.<\/div>\r\n<div style=\"height: 450px; width: 100%; overflow: hidden;\">[h5p id=\"11\"]<\/div>\r\n<p><br \/><\/p>\r\n<!--<div style=\"height: 350px; width: 100%; overflow: hidden;\">[h5p id=\"8\"]<\/div>-->\r\n<h2>alert vs. alertdialog<\/h2>\r\nError, warning, and completion feedback will typically be created with <code>role=\"alert\"<\/code>, while confirmation feedback will often use <code>role=\"alertdialog\"<\/code>. Use <code>role=\"alert\"<\/code> \u00a0when no user input is needed. Use <code>role=\"alertdialog\"<\/code> when user input is expected, with focus sent to the dialog. At least one element in the dialog must be focusable when using <code>role=\"alertdialog\"<\/code>.\r\n\r\nWatch and listen to the following video to understand how ChromeVox handles WAI-ARIA alerts.\r\n\r\n<strong>Video: <a href=\"https:\/\/www.youtube.com\/embed\/JYcWYAe9dJM target=_blank\" rel=\"noopener noreferrer\">WAI-ARIA Alerts<\/a>\u00a0<\/strong>(1:09)\r\n\r\n[embed]https:\/\/www.youtube.com\/embed\/JYcWYAe9dJM[\/embed]\r\n<div style=\"margin: 1em 0; padding: 1em; border: 1px solid #ddd; border-left: 10px solid #0000ff;\"><strong>Suggested Reading:<\/strong> <a href=\"https:\/\/www.w3.org\/TR\/WCAG20-TECHS\/ARIA19.html\">Using ARIA role=\"alert\" or Live Regions to Identify Errors<\/a><\/div>\r\n<h2>Modal Dialogs<\/h2>\r\nModal dialogs interrupt users and require an action. They are appropriate when users' attention needs to be directed toward important information.\r\n\r\nModal dialogs are defined using <code>role=\"alertdialog\"<\/code> and <code>aria-modal=\"true\"<\/code>. Be aware what WAI-ARIA is used for modals, and be aware that when a modal dialog is displayed, focus must be sent to the dialog, and it must remain in the dialog until whatever interaction is complete (e.g., clicking the confirmation button) and the dialog closes. When the dialog closes, focus must be returned to the location from where the dialog was opened.\r\n<h2>Dialogs<\/h2>\r\nDialogs are used like modal dialogs are, except it is still possible to interact with the other content of the page. These are defined using <code>role=\"dialog\"<\/code>.\r\n<div style=\"margin: 1em 0; padding: 1em; border: 1px solid #ddd; border-left: 10px solid #0000ff;\">\r\n\r\n<strong>Suggested Reading:<\/strong>\r\n<ul>\r\n \t<li><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/Accessibility\/ARIA\/ARIA_Techniques\/Using_the_dialog_role\">Using the Dialog Role (Mozilla)<\/a><\/li>\r\n \t<li><a href=\"https:\/\/www.nngroup.com\/articles\/modal-nonmodal-dialog\/\">Modal and Nonmodal Dialogs: When (and When Not) to Use Them<\/a><\/li>\r\n<\/ul>\r\n<\/div>","rendered":"<p>Providing feedback after a user completes an action is a critical accessibility feature. Feedback can be an error message when something has gone wrong. Additionally, it can\u00a0 be a confirmation or warning, after which a user has to make a decision before proceeding. Or, it could be completion feedback that is presented after a particular action has occurred to indicate it was successful.<\/p>\n<p>The latter is often overlooked by developers. However, for people using a screen reader, notification that an action was successful can be as important as providing error messages. When completion feedback is provided, screen reader users do not need to search through the content of the screen to be sure the action they just completed was successful \u2014 the process\u00a0 can be quite time-consuming.<\/p>\n<p>In each type of feedback, it is critical that messages be easy to access. The best strategy for making feedback accessible is to use the WAI-ARIA alert or alert-dialog roles. These are both types of live regions. When the content of the container element with <code>role=\"alert\"<\/code> changes, the content that appears is automatically read aloud by screen readers. A WAI-ARIA alert has an implicit <code>aria-live=\"assertive\"<\/code> and <code>aria-atomic=\"true\"<\/code> (to be covered in more detail in the section on live regions). This means that, when the message appears, it will interrupt whatever the screen reader is in the middle of reading, and the entire content of the element will be read, as opposed to just the new content added (i.e., <code>aria-atomic=\"false\"<\/code>).<\/p>\n<div style=\"margin: 1em 0; padding: 1em; border: 1px solid #ddd; border-left: 10px solid #b9f;\"><strong>Try This:<\/strong> In the following example of a WAI-ARIA alert, start ChromeVox, then press the \u201cSay Something\u201d button to hear how ChromeVox handles the message that appears. Examine the script and HTML below to see how it was done.<\/div>\n<div style=\"height: 450px; width: 100%; overflow: hidden;\">\n<div id=\"h5p-11\">\n<div class=\"h5p-content\" data-content-id=\"11\"><\/div>\n<\/div>\n<\/div>\n<div class=\"wp-nocaption \"><\/div>\n<p><!--\n\n<div style=\"height: 350px; width: 100%; overflow: hidden;\">[h5p id=\"8\"]<\/div>\n\n --><\/p>\n<h2>alert vs. alertdialog<\/h2>\n<p>Error, warning, and completion feedback will typically be created with <code>role=\"alert\"<\/code>, while confirmation feedback will often use <code>role=\"alertdialog\"<\/code>. Use <code>role=\"alert\"<\/code> \u00a0when no user input is needed. Use <code>role=\"alertdialog\"<\/code> when user input is expected, with focus sent to the dialog. At least one element in the dialog must be focusable when using <code>role=\"alertdialog\"<\/code>.<\/p>\n<p>Watch and listen to the following video to understand how ChromeVox handles WAI-ARIA alerts.<\/p>\n<p><strong>Video: <a href=\"https:\/\/www.youtube.com\/embed\/JYcWYAe9dJM target=_blank\" rel=\"noopener noreferrer\">WAI-ARIA Alerts<\/a>\u00a0<\/strong>(1:09)<\/p>\n<p><iframe loading=\"lazy\" id=\"oembed-1\" title=\"WAI-ARIA Alerts\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/JYcWYAe9dJM?feature=oembed&#38;rel=0\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<div style=\"margin: 1em 0; padding: 1em; border: 1px solid #ddd; border-left: 10px solid #0000ff;\"><strong>Suggested Reading:<\/strong> <a href=\"https:\/\/www.w3.org\/TR\/WCAG20-TECHS\/ARIA19.html\">Using ARIA role=&#8221;alert&#8221; or Live Regions to Identify Errors<\/a><\/div>\n<h2>Modal Dialogs<\/h2>\n<p>Modal dialogs interrupt users and require an action. They are appropriate when users&#8217; attention needs to be directed toward important information.<\/p>\n<p>Modal dialogs are defined using <code>role=\"alertdialog\"<\/code> and <code>aria-modal=\"true\"<\/code>. Be aware what WAI-ARIA is used for modals, and be aware that when a modal dialog is displayed, focus must be sent to the dialog, and it must remain in the dialog until whatever interaction is complete (e.g., clicking the confirmation button) and the dialog closes. When the dialog closes, focus must be returned to the location from where the dialog was opened.<\/p>\n<h2>Dialogs<\/h2>\n<p>Dialogs are used like modal dialogs are, except it is still possible to interact with the other content of the page. These are defined using <code>role=\"dialog\"<\/code>.<\/p>\n<div style=\"margin: 1em 0; padding: 1em; border: 1px solid #ddd; border-left: 10px solid #0000ff;\">\n<p><strong>Suggested Reading:<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/Accessibility\/ARIA\/ARIA_Techniques\/Using_the_dialog_role\">Using the Dialog Role (Mozilla)<\/a><\/li>\n<li><a href=\"https:\/\/www.nngroup.com\/articles\/modal-nonmodal-dialog\/\">Modal and Nonmodal Dialogs: When (and When Not) to Use Them<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"author":100,"menu_order":4,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[],"contributor":[],"license":[],"class_list":["post-308","chapter","type-chapter","status-publish","hentry"],"part":31,"_links":{"self":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/wafd\/wp-json\/pressbooks\/v2\/chapters\/308","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/wafd\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/wafd\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/pressbooks.library.torontomu.ca\/wafd\/wp-json\/wp\/v2\/users\/100"}],"version-history":[{"count":38,"href":"https:\/\/pressbooks.library.torontomu.ca\/wafd\/wp-json\/pressbooks\/v2\/chapters\/308\/revisions"}],"predecessor-version":[{"id":2045,"href":"https:\/\/pressbooks.library.torontomu.ca\/wafd\/wp-json\/pressbooks\/v2\/chapters\/308\/revisions\/2045"}],"part":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/wafd\/wp-json\/pressbooks\/v2\/parts\/31"}],"metadata":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/wafd\/wp-json\/pressbooks\/v2\/chapters\/308\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/wafd\/wp-json\/wp\/v2\/media?parent=308"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/pressbooks.library.torontomu.ca\/wafd\/wp-json\/pressbooks\/v2\/chapter-type?post=308"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/pressbooks.library.torontomu.ca\/wafd\/wp-json\/wp\/v2\/contributor?post=308"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/pressbooks.library.torontomu.ca\/wafd\/wp-json\/wp\/v2\/license?post=308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}