Add Custom Dropdown Lists
You can have custom dropdown lists appear when certain hotkeys
are pressed.
When you press a hotkey
inside the Comment Dialog
composer, it will open a dropdown list of items that you can select.
Selecting an item frop the dropdown list will create a chip
that is placed in the comment text.
Get an autocompleteElement instance
First get an autocompleteElement
using one of the following methods:
const autocompleteElement = client.getAutocompleteElement();
const autocompleteElement = useAutocompleteUtils();
Pass hotkey and autocomplete data
Then, use the autocompleteElement.create()
method and pass in a hotkey
and list of autocomplete
data.
#
or /
The list of data will be shown when the hotkey
is pressed.
The Autocomplete
items in the list must be in the following schema:
export class AutocompleteItem {
id!: string;
name!: string;
description?: string;
icon?: { url?: string, svg?: string };
link?: string;
}
Property | Type | Optional | Description |
---|---|---|---|
id | string | No | Unique identifier |
name | string | No | Name of the item |
description | string | Yes | Optional description |
icon | object | Yes | Optional icon information |
- icon.url | string | Yes | URL of the icon |
- icon.svg | string | Yes | SVG representation of icon |
link | string | Yes | Link associated with item |
For example:
let autocompleteData = [
{
id: '1',
name: 'Name 1',
description: 'Test Description 1'
},
{
id: '2',
name: 'Name 2',
description: 'Test Description 2'
},
{
id: '3',
name: 'Name 3',
description: 'Test Description 3'
}
]
autocompleteElement.create({
hotkey: "UNIQUE_HOTKEY", // only single spacial charater is allowed
type: "custom",
list: [], // your autocomplete data here
});
Listen to click event data on chips
When you click on an item in the Autocomplete
dropdown list, a chip will be added in your Comment
.
If you want to listen to click event data when a User clicks on a chip, you can use the following methods and hooks.
This works for chips
from custom dropdowns as well as contact chips
in the @mentions
contacts dropdown.
Hook to get the data of the most recently clicked chip:
let autocompleteChipData = useAutocompleteChipClick();
Was this page helpful?