The FocusListManager class

Each instance of this class is tied to an element. These are created in the bind function for the FocusList directive. This class manages the focus within the element, mainly moving between focus-items with arrow keys.

Constructors

  • Creates an instance of FocusListManager

    Parameters

    • element: HTMLElement

      The focus list's element

    • attributeValue: string

      The value of the v-focus-list attribute which tells the focus list manager the orientation of the list. 'horizontal' means the list should be traversed horizontally, and other value will make the list vertical (including no value).

    Returns FocusListManager

Properties

element: HTMLElement
highlightedItem: HTMLElement
isClicked: boolean
isHorizontal: boolean
isTapped: boolean

Methods

  • Removes 'focused' to the class list of item then updates the tabIndex on subitems (setting them to -1).

    Parameters

    • item: Element

      The element to defocus

    Returns void

  • Adds 'focused' to the class list of item then updates the tabIndex on subitems (setting them to 0).

    Parameters

    • item: HTMLElement

      The element to focus

    Returns void

  • Callback for the BLUR event listener on the focus list element. NOTE: this is only called when the list element stops being focused, not a descendant

    Returns void

  • Callback for the focus event listener on the focus list element. NOTE: this is only called when the LIST ELEMENT is focused, not any descendant

    This is used to pull back the focusedItem id and the aria-activedescendant attribute when a list is focused

    Returns void

  • Updates the list's aria-activedescendant to be item

    Parameters

    • item: HTMLElement

      The element that should be the active descendant

    Returns void

  • Sets tabindex to value for every tabbable thing under focusItem (or the list if not specified)

    Parameters

    • value: number

      the value to give tabindex on each tabbable item

    • focusItem: Element = ...

      the element containing the tabbable items, defaults to the focus list

    Returns void

  • Moves the highlight through the listOfItems forward (or backward) 1 spot

    Parameters

    • listOfItems: HTMLElement[]

      The list of items being moved through

    • reverse: boolean = false

      true iff the highlight should move back one spot

    Returns void