@elemental/ui / Function

focusPreviousElement

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

Presentation

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

Returns

void

Parameters

NameTypeDescription
element
HTMLElement | null

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

wrap
boolean

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

focusProvidedElementIfPreviousNotFound
boolean

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