diff --git a/content/index/index.html b/content/index/index.html index e9f3c4d46c..08a437bcbc 100644 --- a/content/index/index.html +++ b/content/index/index.html @@ -620,6 +620,9 @@

Examples By Properties and States

@@ -124,6 +122,12 @@

Keyboard Support

The example listbox on this page implements the following keyboard interface. Other variations and options for the keyboard interface are described in the Keyboard Interaction section of the Listbox Pattern.

+

+ NOTE: When visual focus is on an option in this listbox implementation, DOM focus remains on the listbox element and the value of aria-activedescendant on the listbox refers to the descendant option that is visually indicated as focused. + Where the following descriptions of keyboard commands mention focus, they are referring to the visual focus indicator, not DOM focus. + For more information about this focus management technique, see + Managing Focus in Composites Using aria-activedescendant. +

@@ -132,6 +136,15 @@

Keyboard Support

+ + + + - + - + - + - + - + - + - + - + - + - + @@ -189,7 +243,7 @@

Role, Property, State, and Tabindex Attributes

- + @@ -201,7 +255,7 @@

Role, Property, State, and Tabindex Attributes

- + + + + + + +
Tab +
    +
  • Moves focus into and out of the listbox.
  • +
  • If the listbox is expanded, selects the focused option, collapses the listbox, and moves focus out of the listbox.
  • +
+
Enter @@ -202,7 +215,7 @@

Role, Property, State, and Tabindex Attributes

aria-labelledby="ID_REF1 ID_REF2"aria-labelledby="ID_REF1 ID_REF2" button
    @@ -214,13 +227,13 @@

    Role, Property, State, and Tabindex Attributes

aria-haspopup="listbox"aria-haspopup="listbox" button Indicates that activating the button displays a listbox.
aria-expanded="true"aria-expanded="true" button
    @@ -237,13 +250,13 @@

    Role, Property, State, and Tabindex Attributes

aria-labelledby="ID_REF"aria-labelledby="ID_REF" ul Refers to the element containing the listbox label.
tabindex="-1"tabindex="-1" ul
    @@ -254,14 +267,13 @@

    Role, Property, State, and Tabindex Attributes

aria-activedescendant="ID_REF"aria-activedescendant="ID_REF" ul
    -
  • Set by the JavaScript when it displays and sets focus on the listbox; otherwise is not present.
  • -
  • Refers to the option in the listbox that is visually indicated as having keyboard focus.
  • +
  • When an option in the listbox is visually indicated as having keyboard focus, refers to that option.
  • +
  • Enables assistive technologies to know which element the application regards as focused while DOM focus remains on the listbox element.
  • When navigation keys, such as Down Arrow, are pressed, the JavaScript changes the value.
  • -
  • Enables assistive technologies to know which element the application regards as focused while DOM focus remains on the ul element.
  • For more information about this focus management technique, see Managing Focus in Composites Using aria-activedescendant. @@ -277,7 +289,7 @@

    Role, Property, State, and Tabindex Attributes

aria-selected="true"aria-selected="true" li diff --git a/content/patterns/listbox/examples/listbox-grouped.html b/content/patterns/listbox/examples/listbox-grouped.html index b3525cc656..8718204fed 100644 --- a/content/patterns/listbox/examples/listbox-grouped.html +++ b/content/patterns/listbox/examples/listbox-grouped.html @@ -15,7 +15,6 @@ - @@ -54,59 +53,97 @@

Example

    -
  • Cat
  • -
  • Dog
  • -
  • Tiger
  • -
  • Reindeer
  • -
  • Raccoon
  • +
  • + + Cat +
  • +
  • + + Dog +
  • +
  • + + Tiger +
  • +
  • + + Reindeer +
  • +
  • + + Raccoon +
    - -
  • Dolphin
  • -
  • Flounder
  • -
  • Eel
  • + +
  • + + Dolphin +
  • +
  • + + Flounder +
  • +
  • + + Eel +
    -
  • Falcon
  • -
  • Winged Horse
  • -
  • Owl
  • +
  • + + Falcon +
  • +
  • + + Winged Horse +
  • +
  • + + Owl +
-

Notes

-

This listbox is scrollable; it has more options than its height can accommodate.

-
    -
  1. - Scrolling only works as expected if the listbox is the options' offsetParent. - The example uses position: relative on the listbox to that effect. -
  2. + + + +
    +

    Accessibility Features

    +
    • - When an option is focused that isn't (fully) visible, the listbox's scroll position is updated: -
        -
      1. If Up Arrow or Down Arrow is pressed, the previous or next option is scrolled into view.
      2. -
      3. If Home or End is pressed, the listbox scrolls all the way to the top or to the bottom.
      4. -
      5. If focusItem is called, the focused option will be scrolled to the top of the view if it was located above it or to the bottom if it was below it.
      6. -
      7. If the mouse is clicked on a partially visible option, it will be scrolled fully into view.
      8. -
      + Because this listbox implementation is scrollable and manages which option is focused by using aria-activedescendant, the JavaScript must ensure the focused option is visible. + So, when a keyboard or pointer event changes the option referenced by aria-activedescendant, if the referenced option is not fully visible, the JavaScript scrolls the listbox to position the option in view.
    • -
    • When a fully visible option is focused in any way, no scrolling occurs.
    • - Normal scrolling through any scrolling mechanism (including Page Up and Page Down) works as expected. - The scroll position will jump as described for focusItem if a means other than a mouse click is used to change focus after scrolling. + To enhance perceivability when operating the listbox, visual keyboard focus and hover are styled using the CSS :hover and :focus pseudo-classes: +
        +
      • To help people with visual impairments identify the listbox as an interactive element, the cursor is changed to a pointer when hovering over the list.
      • +
      • To make it easier to distinguish the selected listbox option from other options, selection creates a 2 pixel border above and below the option.
      • +
    • -
+

Keyboard Support

- The example listboxes on this page implement the following keyboard interface. + The example listbox on this page implements the following keyboard interface. Other variations and options for the keyboard interface are described in the Keyboard Interaction section of the Listbox Pattern.

+

+ NOTE: When visual focus is on an option in this listbox implementation, DOM focus remains on the listbox element and the value of aria-activedescendant on the listbox refers to the descendant option that is visually indicated as focused. + Where the following descriptions of keyboard commands mention focus, they are referring to the visual focus indicator, not DOM focus. + For more information about this focus management technique, see + Managing Focus in Composites Using aria-activedescendant. +

@@ -115,6 +152,10 @@

Keyboard Support

+ + + + @@ -131,6 +172,15 @@

Keyboard Support

+ + + +
TabMoves focus into and out of the listbox.
Down Arrow Moves focus to and selects the next option. End Moves focus to and selects the last option.
Printable Characters +
    +
  • Type a character: focus moves to the next item with a name that starts with the typed character.
  • +
  • Type multiple characters in rapid succession: focus moves to the next item with a name that starts with the string of characters typed.
  • +
+
@@ -159,25 +209,29 @@

Role, Property, State, and Tabindex Attributes

aria-labelledby="ID_REF"aria-labelledby="ID_REF" div Refers to the element containing the listbox label.
tabindex="0"tabindex="0" div Includes the listbox in the page tab sequence.
aria-activedescendant="ID_REF"aria-activedescendant="ID_REF" div
    -
  • Tells assistive technologies which of the options, if any, is visually indicated as having keyboard focus.
  • -
  • DOM focus remains on the ul element and the idref specified for aria-activedescendant refers to the li element that is visually styled as focused.
  • +
  • When an option in the listbox is visually indicated as having keyboard focus, refers to that option.
  • +
  • Enables assistive technologies to know which element the application regards as focused while DOM focus remains on the listbox element.
  • When navigation keys, such as Down Arrow, are pressed, the JavaScript changes the value.
  • +
  • + For more information about this focus management technique, see + Managing Focus in Composites Using aria-activedescendant. +
aria-labelledby="ID_REF"aria-labelledby="ID_REF" ul Refers to the element containing the option group label.
aria-selected="true"aria-selected="true" li
    @@ -211,6 +265,14 @@

    Role, Property, State, and Tabindex Attributes

aria-hidden="true"span + Removes the character entity used for the check mark icon from the accessibility tree to prevent it from being included in the accessible name of the option. +
@@ -224,7 +286,7 @@

JavaScript and CSS Source Code

  • Javascript: - listbox.js, listbox-scrollable.js, utils.js + listbox.js, listbox-scrollable.js
  • diff --git a/content/patterns/listbox/examples/listbox-rearrangeable.html b/content/patterns/listbox/examples/listbox-rearrangeable.html index 5367d021eb..88d29d9a3d 100644 --- a/content/patterns/listbox/examples/listbox-rearrangeable.html +++ b/content/patterns/listbox/examples/listbox-rearrangeable.html @@ -15,7 +15,6 @@ - @@ -59,56 +58,89 @@

    Example 1: Single-Select Listbox

    Important Features: -
    Unimportant Features: - - + +
    Last change:
    -

    Notes

    -
      -
    1. - Assistive technologies are told which option in the list is visually focused by the value of aria-activedescendant: -
        -
      1. DOM focus remains on the listbox element.
      2. -
      3. When a key that moves focus is pressed or an option is clicked, JavaScript changes the value of aria-activedescendant on the listbox element.
      4. -
      5. If the listbox element does not contain any options, aria-activedescendant does not have a value.
      6. -
      -
    2. -
    3. - When Tab moves focus into either listbox: -
        -
      1. If none of the options are selected, the first option receives focus.
      2. -
      3. If an option is selected, the selected option receives focus.
      4. -
      -
    4. -
    5. Only one option may be selected at a time (have aria-selected="true").
    6. -
    7. - As the user moves focus in the list, selection also moves. - That is, both the value of aria-activedescendant and the element that has aria-selected="true" change. -
    8. -
    @@ -121,73 +153,99 @@

    Example 2: Multi-Select Listbox

    Available upgrades: -
      -
    • Leather seats
    • -
    • Front seat warmers
    • -
    • Rear bucket seats
    • -
    • Rear seat warmers
    • -
    • Front sun roof
    • -
    • Rear sun roof
    • -
    • Cloaking capability
    • -
    • Food synthesizer
    • -
    • Advanced waste recycling system
    • -
    • Turbo vertical take-off capability
    • +
        +
      • + + Leather seats +
      • +
      • + + Front seat warmers +
      • +
      • + + Rear bucket seats +
      • +
      • + + Rear seat warmers +
      • +
      • + + Front sun roof +
      • +
      • + + Rear sun roof +
      • +
      • + + Cloaking capability +
      • +
      • + + Food synthesizer +
      • +
      • + + Advanced waste recycling system +
      • +
      • + + Turbo vertical take-off capability +
      - +
    Upgrades you have chosen: -
      - +
        +
      +
      Last change:
      -

      Notes

      -
        -
      1. - Like in example 1, assistive technologies are told which option in the list is visually focused by the value of aria-activedescendant: -
          -
        1. DOM focus remains on the listbox element.
        2. -
        3. When a key that moves focus is pressed or an option is clicked, JavaScript changes the value of aria-activedescendant on the listbox element.
        4. -
        5. If the listbox element does not contain any options, aria-activedescendant does not have a value.
        6. -
        -
      2. -
      3. - When Tab moves focus into either listbox: -
          -
        1. If none of the options are selected, focus is set on the first option.
        2. -
        3. If one or more options are selected, focus is set on the first selected option.
        4. -
        -
      4. -
      5. - Unlike example 1, more than one option may be selected at a time (have aria-selected="true"). -
          -
        1. The multi-select capability is communicated to assistive technologies by setting aria-multiselectable="true" on the listbox element.
        2. -
        3. All option elements have a value set for aria-selected.
        4. -
        5. Selected options have aria-selected set to true and all others have it set to false.
        6. -
        7. Keys that move focus do not change the selected state of an option.
        8. -
        -
      6. -
      7. Users can toggle the selected state of the focused option with Space or click.
      8. -

      Accessibility Features

      -
        +
      1. In example 1, since there are four action buttons, a toolbar widget is used to group all the action buttons into a single tab stop.
      2. Live regions provide confirmation of completed actions.
      3. -
      +
    • + Because this listbox implementation is scrollable and manages which option is focused by using aria-activedescendant, the JavaScript must ensure the focused option is visible. + So, when a keyboard or pointer event changes the option referenced by aria-activedescendant, if the referenced option is not fully visible, the JavaScript scrolls the listbox to position the option in view. +
    • +
    • + To enhance perceivability when operating the listbox, visual keyboard focus and hover are styled using the CSS :hover and :focus pseudo-classes: + +
    • +
      @@ -214,6 +283,12 @@

      Keyboard Support

      The example listboxes on this page implement the following keyboard interface. Other variations and options for the keyboard interface are described in the Keyboard Interaction section of the Listbox Pattern.

      +

      + NOTE: When visual focus is on an option in these implementations of listbox, DOM focus remains on the listbox element and the value of aria-activedescendant on the listbox refers to the descendant option that is visually indicated as focused. + Where the following descriptions of keyboard commands mention focus, they are referring to the visual focus indicator, not DOM focus. + For more information about this focus management technique, see + Managing Focus in Composites Using aria-activedescendant. +

      @@ -222,6 +297,18 @@

      Keyboard Support

      + + + + + + + +
      Tab +
        +
      • Moves focus into and out of the listbox.
      • +
      • + When the listbox receives focus, if none of the options are selected, the first option receives focus. + Otherwise, the first selected option receives focus. +
      • +
      +
      Down Arrow @@ -258,15 +345,23 @@

      Keyboard Support

      Printable Characters +
        +
      • Type a character: focus moves to the next item with a name that starts with the typed character.
      • +
      • Type multiple characters in rapid succession: focus moves to the next item with a name that starts with the string of characters typed.
      • +
      +

      Multiple selection keys supported in example 2

      -
      -

      Note

      -

      The selection behavior demonstrated differs from the behavior provided by browsers for native HTML <select multiple> elements. +

      + NOTE: The selection behavior demonstrated differs from the behavior provided by browsers for native HTML <select multiple> elements. The HTML select element behavior is to alter selection with unmodified up/down arrow keys, requiring the use of modifier keys to select multiple options. - This example demonstrates the multiple selection interaction model recommended in the Keyboard Interaction section of the Listbox Pattern, which does not require the use of modifier keys.

      -
      + This example demonstrates the multiple selection interaction model recommended in the Keyboard Interaction section of the Listbox Pattern, which does not require the use of modifier keys. +

      @@ -333,19 +428,19 @@

      Role, Property, State, and Tabindex Attributes

      - + - + - + - + @@ -376,7 +475,7 @@

      Role, Property, State, and Tabindex Attributes

      - + - + + + + + + +
      aria-labelledby="ID_REF"aria-labelledby="ID_REF" ul Applied to the element with the listbox role, it refers to the span containing its label.
      tabindex="0"tabindex="0" ul Applied to the element with the listbox role, it puts the listbox in the tab sequence.
      aria-multiselectable="true"aria-multiselectable="true" ul
        @@ -357,14 +452,18 @@

        Role, Property, State, and Tabindex Attributes

      aria-activedescendant="ID_REF"aria-activedescendant="ID_REF" ul
        -
      • Applied to the element with the listbox role, tells assistive technologies which of the options, if any, is visually indicated as having keyboard focus.
      • -
      • DOM focus remains on the ul element and the idref specified for aria-activedescendant refers to the li element that is visually styled as focused.
      • +
      • When an option in the listbox is visually indicated as having keyboard focus, refers to that option.
      • +
      • Enables assistive technologies to know which element the application regards as focused while DOM focus remains on the listbox element.
      • When navigation keys, such as Down Arrow, are pressed, the JavaScript changes the value.
      • -
      • When the listbox is empty, aria-activedescendant="".
      • +
      • When the listbox is empty, aria-activedescendant="".
      • +
      • + For more information about this focus management technique, see + Managing Focus in Composites Using aria-activedescendant. +
      aria-selected="true"aria-selected="true" li
        @@ -389,7 +488,7 @@

        Role, Property, State, and Tabindex Attributes

      aria-selected="false"aria-selected="false" li
        @@ -399,6 +498,14 @@

        Role, Property, State, and Tabindex Attributes

      aria-hidden="true"span + Removes the character entities used for the check mark, left arrow and right arrow from the accessibility tree to prevent them from being included in the accessible name of an option or button. +
      @@ -412,7 +519,7 @@

      JavaScript and CSS Source Code

    • Javascript: - listbox.js, toolbar.js, listbox-rearrangeable.js, utils.js + listbox.js, toolbar.js, listbox-rearrangeable.js
    • diff --git a/content/patterns/listbox/examples/listbox-scrollable.html b/content/patterns/listbox/examples/listbox-scrollable.html index 1b54fd87f7..3dbb24ce3a 100644 --- a/content/patterns/listbox/examples/listbox-scrollable.html +++ b/content/patterns/listbox/examples/listbox-scrollable.html @@ -15,7 +15,6 @@ - @@ -53,67 +52,146 @@

      Example

      Transuranium elements:
      -

      Notes

      -

      This listbox is scrollable; it has more options than its height can accommodate.

      -
        -
      1. - Scrolling only works as expected if the listbox is the options' offsetParent. - The example uses position: relative on the listbox to that effect. -
      2. + + +
        +

        Accessibility Features

        +
      +

      Keyboard Support

      - The example listboxes on this page implement the following keyboard interface. + The example listbox on this page implements the following keyboard interface. Other variations and options for the keyboard interface are described in the Keyboard Interaction section of the Listbox Pattern.

      +

      + NOTE: When visual focus is on an option in this listbox implementation, DOM focus remains on the listbox element and the value of aria-activedescendant on the listbox refers to the descendant option that is visually indicated as focused. + Where the following descriptions of keyboard commands mention focus, they are referring to the visual focus indicator, not DOM focus. + For more information about this focus management technique, see + Managing Focus in Composites Using aria-activedescendant. +

      @@ -122,6 +200,10 @@

      Keyboard Support

      + + + + @@ -138,6 +220,15 @@

      Keyboard Support

      + + + +
      TabMoves focus into and out of the listbox.
      Down Arrow Moves focus to and selects the next option. End Moves focus to and selects the last option.
      Printable Characters +
        +
      • Type a character: focus moves to the next item with a name that starts with the typed character.
      • +
      • Type multiple characters in rapid succession: focus moves to the next item with a name that starts with the string of characters typed.
      • +
      +
      @@ -145,7 +236,7 @@

      Keyboard Support

      Role, Property, State, and Tabindex Attributes

      - The example listboxes on this page implement the following ARIA roles, states, and properties. + The example listbox on this page implements the following ARIA roles, states, and properties. Information about other ways of applying ARIA roles, states, and properties is available in the Roles, States, and Properties section of the Listbox Pattern.

      @@ -166,25 +257,29 @@

      Role, Property, State, and Tabindex Attributes

      - + - + - + @@ -196,7 +291,7 @@

      Role, Property, State, and Tabindex Attributes

      - + + + + + + +
      aria-labelledby="ID_REF"aria-labelledby="ID_REF" ul Refers to the element containing the listbox label.
      tabindex="0"tabindex="0" ul Includes the listbox in the page tab sequence.
      aria-activedescendant="ID_REF"aria-activedescendant="ID_REF" ul
        -
      • Tells assistive technologies which of the options, if any, is visually indicated as having keyboard focus.
      • -
      • DOM focus remains on the ul element and the idref specified for aria-activedescendant refers to the li element that is visually styled as focused.
      • +
      • When an option in the listbox is visually indicated as having keyboard focus, refers to that option.
      • +
      • Enables assistive technologies to know which element the application regards as focused while DOM focus remains on the listbox element.
      • When navigation keys, such as Down Arrow, are pressed, the JavaScript changes the value.
      • +
      • + For more information about this focus management technique, see + Managing Focus in Composites Using aria-activedescendant. +
      aria-selected="true"aria-selected="true" li
        @@ -206,6 +301,14 @@

        Role, Property, State, and Tabindex Attributes

      aria-hidden="true"span + Removes the character entity used for the check mark icon from the accessibility tree to prevent it from being included in the accessible name of the option. +
      @@ -219,7 +322,7 @@

      JavaScript and CSS Source Code

    • Javascript: - listbox.js, listbox-scrollable.js, utils.js + listbox.js, listbox-scrollable.js
    • diff --git a/test/tests/listbox_grouped.js b/test/tests/listbox_grouped.js index 8b4846e1c3..32ef9927f1 100644 --- a/test/tests/listbox_grouped.js +++ b/test/tests/listbox_grouped.js @@ -96,6 +96,20 @@ ariaTest( } ); +ariaTest( + 'aria-hidden="true" on li > span.checkmark elements', + exampleFile, + 'span-aria-hidden', + async (t) => { + await assertAttributeValues( + t, + `${ex.optionSelector} span.checkmark`, + 'aria-hidden', + 'true' + ); + } +); + ariaTest( '"aria-selected" on option elements', exampleFile, diff --git a/test/tests/listbox_rearrangeable.js b/test/tests/listbox_rearrangeable.js index 0010fbb5d8..4f46856fd1 100644 --- a/test/tests/listbox_rearrangeable.js +++ b/test/tests/listbox_rearrangeable.js @@ -15,6 +15,7 @@ const ex = { listboxSelector: '#ex1 [role="listbox"]', importantSelector: '#ex1 [role="listbox"]#ss_imp_list', optionSelector: '#ex1 [role="option"]', + spanSelector: '#ex1 span.checkmark', numOptions: 10, firstOptionSelector: '#ex1 #ss_opt1', lastOptionSelector: '#ex1 #ss_opt10', @@ -23,6 +24,7 @@ const ex = { listboxSelector: '#ex2 [role="listbox"]', availableSelector: '#ex2 [role="listbox"]#ms_imp_list', optionSelector: '#ex2 [role="option"]', + spanSelector: '#ex2 span.checkmark', numOptions: 10, firstOptionSelector: '#ex2 #ms_opt1', lastOptionSelector: '#ex2 #ms_opt10', @@ -122,6 +124,16 @@ ariaTest( } ); +ariaTest( + 'aria-hidden="true" on span[class=checkmark] elements', + exampleFile, + 'span-aria-hidden', + async (t) => { + await assertAttributeValues(t, ex[1].spanSelector, 'aria-hidden', 'true'); + await assertAttributeValues(t, ex[2].spanSelector, 'aria-hidden', 'true'); + } +); + ariaTest( 'role="option" on li elements', exampleFile, diff --git a/test/tests/listbox_scrollable.js b/test/tests/listbox_scrollable.js index cba46a1abf..d33b474880 100644 --- a/test/tests/listbox_scrollable.js +++ b/test/tests/listbox_scrollable.js @@ -11,6 +11,7 @@ const exampleFile = 'content/patterns/listbox/examples/listbox-scrollable.html'; const ex = { listboxSelector: '#ex [role="listbox"]', optionSelector: '#ex [role="option"]', + spanSelector: '#ex [role="option"] span.checkmark', numOptions: 26, firstOptionSelector: '#ex #ss_elem_Np', }; @@ -78,6 +79,15 @@ ariaTest( } ); +ariaTest( + 'aria-hidden="true" on li > span elements', + exampleFile, + 'span-aria-hidden', + async (t) => { + await assertAttributeValues(t, ex.spanSelector, 'aria-hidden', 'true'); + } +); + ariaTest( '"aria-selected" on option elements', exampleFile,