Skip to content

Events

PropertyTypeDescription
onChangefunction(optional) Will be called on state changes made by the user. Returns an object with the new selected data item { data, event, attributes, value }.
onSelectfunction(optional) Will be called once the user focuses or selects an item by a click or keyboard navigation. Returns an object with the new selected data item { data, event, attributes, value, activeItem }. The activeItem property is the currently selected item by keyboard navigation.
onOpenfunction(optional) Will be called once the user presses the dropdown. Returns the data item { data, attributes }.
onClosefunction(optional) Will be called once the user presses the dropdown again, or clicks somewhere else. Returns the data item { data, attributes }.
onOpenFocusfunction(optional) Will be called when focus is set on an item inside the opened drawer list. Returns { element } with the focused DOM element.
onCloseFocusfunction(optional) Will be called when focus is moved back to the trigger button after the drawer list closes. Returns { element } with the focused DOM element.

The onChange vs onSelect difference

The difference between onChange and onSelect is:

  • onChange will be called when the state changes, either with a click or space/enter keypress confirmation.
  • onSelect differs most when the user is navigating by keyboard. Once the user is pressing e.g. the arrow keys, the selection is changing, but not the state.