Would you like a live region?

old-timey advertisement for snake oil, with the text updated to say: would you like a live region? Made by: the ARIA WG. in the center is a picture of someone in a top hat flanked by two stylized snakes. The head of the person is updated to be an avatar of Sarah Higley

Ingredients

  1. The Pitch
  2. Practical Examples
  3. Testing

Do you:

  • Like using all caps?
  • Sometimes wish you could yell specifically at people using a screen reader?

Try Dr. Aria's Live Regions

old-timey quack patent medicine add showing 4 adults and 2 chilren sitting around a table and passing around boxes of medicine, and in the foreground are a bunch of medicine boxes with a lot of writing, including things like smart weed, water pepper, and a cure for chronic weakness and female complaints.

Side effects may include:

swearing leaving at a run spontaneous combustion flipping the bird

Not intended for:

young children the elderly person with a heart condition person experiencing stress person with anxiety anyone who doesn't like getting shouted at

< pause for tomato throwing >

What is a notification?

Hi! It me!

What is a live region?

Is it a notification?

Hi! It me!
  • aria-live="assertive"
  • aria-live="polite"
  • role="alert"
  • role="status"

Practicum

Sample shipping form with three fields: name, street address, and city. The first two fields show red form errors marked up with arrows pointing to them

role="alert" insertion

Loading...

screenshot of a downloads dialog with a visual progressbar and text that says there have been 25 files downloaded

Demo code (before) | Demo code (after)

      But how do I apply live regions here? Help!

      a old timey glass bottle with blue liquid, and the label says dr. jake dawson's liniment tonic, snake oil. 50 cents.

      Don't worry!

      Dr. ARIA's patented live regions can fix every ailment!

      
      						function onInput(event) {
      							// cancel the timeout any time a user types
      							clearTimeout(id);
      
      							// start a new timeout to announce a message
      							// if the user stops typing
      							id = setTimeout(() => {
      								announce('10 results found');
      							}, 500);
      						}
      					

        It also works here!

        screenshot of a textarea with text asking to place an order for live regions, and a word count below the text, currently at 229 of 500. screenshot of the same textarea with more text in it, the word count is now red and at 503 of 500, and there are red exclamation mark annotations scribbled over the screenshot.

        WARNING:
        Please consult a doctor for any of the following:

        More than one simultaneous loading region

        way too many skeleton loaders on a page, arranged in roughly 3 sections with about 8 rows of shimmering loaders each

        Using a live region to communicate what a focus change already did.

        Wrapping any type of input in a live region

        Wrapping any major section of changing content in a live region

        screenshot of a chat pane between you and CatBot. You asked what are cats, and CatBot replied with information on cats first being domesticated in ancient egypt.

        Side effects include:

        • Headaches, nausea, dizzyness...
        • No control over timing and frequency of updates
        • No control over visual vs. announced verbosity
        • No ability to filter out repetitive & supplementary content
        • Too many announcements that are too verbose

        Chatbots: a shallow dive

        screenshot of part of a chat UI. The sent message says what are cats, and there is a message with a loading bar saying generating reply... followed by a stop generating button. Below that is an input with placeholder text that says ask me anything about cats.

        Field testing snake oil live regions

        old advertisement for hamlin's wizard oil. For some inexplicable reason there is a giant elephant in the middle of a street, with a man followed by two clowns painting the words Hamlin's wizard oil - cures all pain in man or beast on the elephant's back. A strange and chaotic parade is also happening on the street for no clear reason.

        Be intentional about message text

        a single chat message containing the following: a cat avatar followed by the name CatBot, a generated from wikipedia tag, a block of message text about taming african wildcats, and a set of 5 icon buttons including copy, share, more actions, etc.
        CatBot said: The earliest known indication for the taming of an African wildcat was excavated close by a human Neolithic grave in Shillourokambos, southern Cyprus, dating to about 7500-7200 BC.

        Do NOT wrap streaming content in a live region

        an old advertisement for cocaine toothache drops for 15 cents, featuring two very young children playing outside.

        It can be good!

        “That’s really what you’d like it to do, right, is just read it automatically so I don’t have to look around.” - Jennifer
        “I really liked whenever I pressed enter, you know, I liked how it said “generating reply, generating reply, still generating reply, that part was actually pretty cool. And I also liked how it actually read out the response — the entire response.” - Miguel

        BUT. Live regions everywhere ≠ good

        Do NOT use live regions to build a custom in-page screen reader

        Any sufficiently complex application should have central live region handling

        • Handle batching back-to-back loading/loaded announcements
        • Only need one live region node in the page
        • Allows components to fire a live region on insertion
        • Better testing and debugging

        Testing

        A three-tier array of patent medicine bottles sold at May's in Pittsburg PA. There are soaps, salves, pills, syrups, and more. It appears to be a newspaper ad.

        First: authoring error?

        Check the following:

        • The live region exists on the page before text is added
        • Is there a simultaneous conflicting event, e.g. a focus change?
        • Is the live region outside an open dialog?
        • Is the live region actually updating its inner text?

        Second: browser or screen reader error?

        • Check the screen reader speech log for immediately overridden text
        • Advanced: check the API events

        Live debugging: MutationObserver

        
        						function observeElement(element) {
        							const config = {
        								attributes: true,
        								childList: true,
        								subtree: true
        							};
        							const callback = function(mutationsList, observer) {
        							  for(let mutation of mutationsList) {
        								  if (mutation.type === 'childList') {
        									const additions = mutation.addedNodes;
        									const removals = mutation.removedNodes;
        						// etc.
        					

        code: MutationObserver gist

        Closing thoughts

        an illustration of a man with white sideburns and a grey suit and top hat gestures grandly at a tiny medicine bottle with his mouth open comically

        Notification center

        github notification center showing bell icon in the top bar and the page content is a notification inbox with two unread messages

        ariaNotify

        
        						ariaNotify('Help my web page is yelling at me');
        					

        Remember:

        ariaNotify('do not SCREAM at your users');

        Only scream at developers

        (who abuse live regions)

        Thank you!

        Slides: smhigley.github.io/slides/have-a-notification/workshop

        Code examples: github.com/smhigley/notification-workshop