Dropdown

dropdown:before:close#

Hook emitted before dropdown close.

Type: hook (handler may return a value).

Payload:

  • dropdown — Dropdown instance
  • reason — close reason string

Example:

app.on('dropdown:before:close', ({ reason }) => {
  if (reason === 'escape') saveDraftField();
});

dropdown:before:open#

Hook emitted before a dropdown opens. Return a value to override open behavior.

Type: hook (handler may return a value).

Payload:

  • dropdown — Dropdown instance

Example:

app.on('dropdown:before:open', ({ dropdown }) => {
  dropdown.setMaxWidth('280px');
});

dropdown:close#

Emitted when a dropdown closes.

Type: signal.

Payload: none.

Example:

app.on('dropdown:close', () => {
  clearDropdownOverlay();
});

dropdown:item:before:command#

Hook emitted before a dropdown item command runs.

Type: hook (handler may return a value).

Payload:

  • dropdown — Dropdown instance
  • itemEl — clicked item element
  • itemName — item command name
  • command — command string passed to app.invoke
  • params — command params object

Example:

app.on('dropdown:item:before:command', ({ command, params }) => {
  if (command === 'block.insert') params.attrs = { 'data-tracked': '1' };
});

dropdown:item:command#

Emitted after a dropdown item command runs.

Type: signal.

Payload:

  • dropdown — Dropdown instance
  • itemEl — clicked item element
  • itemName — item command name
  • command — invoked command string
  • params — command params object
  • result — return value from app.invoke

Example:

app.on('dropdown:item:command', ({ command, result }) => {
  if (command === 'format.set') logFormatApplied(result);
});

dropdown:items:render#

Emitted when dropdown items are rendered.

Type: signal.

Payload:

  • dropdown — Dropdown instance
  • target — container element for items
  • items — rendered item configs

Example:

app.on('dropdown:items:render', ({ items }) => {
  items.forEach((item) => { if (item.name === 'todo') item.title = 'Checklist'; });
});

dropdown:open#

Emitted when a dropdown opens.

Type: signal.

Payload:

  • dropdown — Dropdown instance

Example:

app.on('dropdown:open', ({ dropdown }) => {
  console.log('opened', dropdown.type);
});

dropdown:tab:change#

Emitted when the active tab inside a dropdown changes.

Type: signal.

Payload:

  • dropdown — Dropdown instance
  • from — previous tab name
  • to — new tab name

Example:

app.on('dropdown:tab:change', ({ from, to }) => {
  analytics.track('dropdown-tab', { from, to });
});