ClearFocus Command


ClearFocus requires APL 1.1 or later. Provide an alternate experience for devices running older versions of APL.

Removes focus from the actionable component that has focus. For details about the components that can receive and lose focus, see Focused.

Because only one component can have focus at a time, ClearFocus always affects at most one component.

When ClearFocus runs, the command removes focus from the component that has it, and sets the focused state for that component to false.

Properties

The ClearFocus command has no properties other than the common command properties. Set the type property to ClearFocus.

For example, to clear focus from any component that has it:

{
  "type": "ClearFocus"
}

The ClearFocus command runs in fast mode, but without any delay.

ClearFocus example

The following example uses the onMount handler to set the focus to the first item in the list. The SetFocus button changes the focus to the next item in the list. Click the Clear all focus button to run the ClearFocus command.



Was this page helpful?

Last updated: frontmatter-missing