Focus

Documentation and test page for the UCASUtilities.focus component.

lost()

UCASUtilities.focus.lost(identifier) // Reports lost focus.

This will check that nothing has focus, and if so, will emit a focusLost event.

This can be used when a button or other trigger removes the content that currently has focus. It emits an event which can be used to reset the focus on an appropriate element. See the dynamic content test on the Multiaction buttons page for an example.

focus()

UCASUtilities.focus.focus(el) // Sets new focus.

Focusable elements are:
a, button, input, textarea, select, summary, [tabindex]:not([tabindex="-1"])

isFocusable()

UCASUtilities.focus.isFocusable(el) // Determines if an element is focusable.

listFocusableElements()

UCASUtilities.focus.listFocusableElements(context) // Lists all focusable elements within an element or the document.

next()

UCASUtilities.focus.next() // Moves focus to next focusable element.

prev()

UCASUtilities.focus.prev() // Moves focus to previous focusable element.