@elemental/ui / Function

focusNextElement

Focuses on the next focusable element relative to the provided element.

Presentation

function focusNextElement(
  element: HTMLElement | null,
  wrap: boolean = false,
  focusProvidedElementIfNextNotFound: boolean = true,
): void;

Returns

void

Parameters

NameTypeDescription
element
HTMLElement | null

@param element The element from which to find the next focusable element.

wrap
boolean

@param wrap If true, when reaching the end of the focusable elements, it wraps around to the beginning.

focusProvidedElementIfNextNotFound
boolean

@param focusProvidedElementIfNextNotFound If true and no next focusable element is found, focus remains on the provided element.