class FocusFirstCommand implements CommandInterface (View source)

AJAX command for focusing an element.

This command is provided a selector then does the following:

  • The first element matching the provided selector will become the container where the search for tabbable elements is conducted.
  • If one or more tabbable elements are found within the container, the first of those will receive focus.
  • If no tabbable elements are found within the container, but the container itself is focusable, then the container will receive focus.
  • If the container is not focusable and contains no tabbable elements, the triggering element will remain focused.

Properties

protected string $selector

The selector of the container with tabbable elements.

Methods

__construct(string $selector)

Constructs an FocusFirstCommand object.

render()

Return an array to be run through json_encode and sent to the client.

Details

__construct(string $selector)

Constructs an FocusFirstCommand object.

Parameters

string $selector

The selector of the container with tabbable elements.

render()

Return an array to be run through json_encode and sent to the client.