Skip to main content

PopupPickerController

Controls the lifecycle of a popup picker. The controller has an underlying EmojiPicker that is rendered in the popup.

Properties

isOpen

  • Type: boolean

Reflects the current visibility state of the picker.

picker

The picker being managed by this controller.

referenceElement

  • Type: HTMLElement | undefined

The current reference element, if any, used for positioning the popup.

This defaults to the value passed in the PopupOptions, if any. If the picker is opened with a new reference element, this property will be updated with the new reference element.

triggerElement

  • Type: HTMLElement | undefined

The current trigger element, if any, used to toggle the popup.

This defaults to the value passed in the PopupOptions, if any. If the picker is opened with a new trigger element, this property will be updated with the new trigger element.

Methods

addEventListener

addEventListener(event: PopupEvent, callback: function): void

Adds an event listener to the picker.

Arguments

  • event: The event to listen for.
  • listener: The function to call when this event is emitted.
    • Type: function

close

close(): Promise<void>

Closes the picker.

Return value

A Promise that resolves when the picker has closed.

destroy

destroy(): Promise<void>

Destroys the picker when it is no longer needed. After calling this method, the picker will no longer be usable.

If the picker is currently open, it will be closed before being destroyed.

Return value

A Promise that resolves when the picker has been closed and destroyed.

open

open(options: OpenOptions | undefined): Promise<void>

Opens the picker.

Arguments

  • options: Optional options object to set new reference and trigger elements.

Return value

A Promise that resolves when the picker has opened.

removeEventListener

removeEventListener(event: PopupEvent, callback: function): void

Removes an event listener from the picker.

Arguments

  • event: The event to stop listening for.
  • listener: The previously registered listener function to remove.
    • Type: function

toggle

toggle(options: OpenOptions | undefined): Promise<void>

Toggles the state of the picker. If it is closed, it will be opened with the specified options; if it is open, it will be closed.

Arguments

  • options: Optional options object to pass when toggling the picker open.

Return value

A Promise that resolves when the picker has finished opening or closing.