Migrating from UIDropdown to HighRise Dropdown
Migrating from ghl-ui Dropdown to HighRise Dropdown
This guide will help you migrate from the ghl-ui Dropdown component to the new HighRise Dropdown component.
Component Implementation Changes
Import Changes
diff
- import { UIDropdown } from '@gohighlevel/ghl-ui'
+ import { HLDropdown } from '@platform-ui/highrise'
Basic Usage Changes
diff
- <UIDropdown :options="options">
- <UIButton>Click me</UIButton>
- </UIDropdown>
+ <HLDropdown
+ id="my-dropdown"
+ :options="options"
+ trigger="click"
+ placement="bottom-start"
+ :show-search="false"
+ >
+ <HLButton>Click me</HLButton>
+ </HLDropdown>
INFO
show-search
should be set to false by default.
Props Changes
Required Changes
ghl-ui Prop | HighRise Prop | Notes |
---|---|---|
- | id | New required prop for accessibility |
options | options | Enhanced options format with new features |
trigger | trigger | Values: 'click', 'hover', 'focus' (default: 'click') |
placement | placement | More placement options available |
- | showArrow | New prop to control arrow visibility |
- | width | New prop to control dropdown width (default: 182px) |
- | showSelectedMark | New prop to show checkmark for selected items |
- | treeMode | New prop for hierarchical navigation |
- | showSearch | New prop to enable search functionality , set to false by default |
Options Format
The HighRise Dropdown supports an enhanced options format with additional features:
typescript
interface HLDropdownOption {
key: string | number
label: string
type?: 'default' | 'divider' | 'header' | 'search' | 'avatar' | 'icon' | 'render' | 'link'
children?: HLDropdownOption[]
selected?: boolean
href?: string
target?: string
description?: string
descriptionIcon?: string
infoText?: string
prefix?: boolean
prefixHandler?: () => void
titleRightSlot?: () => VNode
searchPlaceholder?: string
onChange?: (value: string) => void
}
Examples
Basic Dropdown
vue
<template>
<HLDropdown
id="basic-dropdown"
:show-search="false"
:options="[
{ key: '1', label: 'Option 1' },
{ key: '2', label: 'Option 2' },
{ key: '3', label: 'Option 3' },
]"
>
<HLButton>Open Menu</HLButton>
</HLDropdown>
</template>
Dropdown with custom options
INFO
- In GHL-UI, the
render-option
prop is used for custom rendering of the dropdown options. - In HighRise, the option needs to be customized using the
render
type in the options array and passing a h() function to render the option. renderLabel
is currently not supported in HighRise.
diff
- <UIDropdown
- :options="contextMenuItems"
- :id="'folderMenu'"
- placement="bottom"
- @select="onChangeOption"
- :render-option="(option:any) => selectOptionsComponent(option)"
- >
- <UIButton>
- Click to open dropdown
- </UIButton>
- </UIDropdown>
+ <HLDropdown
+ id="folderMenu"
+ :options="contextMenuItems"
+ placement="bottom"
+ @select="onChangeOption"
+ :options="[
+ ...contextMenuItems,
+ { key: '4', label: 'Option 4', type: 'render', render: () => h('div', 'Option 4') },
+ ]"
+ >
+ <HLButton>
+ Click to open dropdown
+ </HLButton>
+ </HLDropdown>
With Search and Selected Items
vue
<template>
<HLDropdown id="searchable-dropdown" :options="options" show-selected-mark :width="250" :show-search="false">
<HLButton>Select Items</HLButton>
</HLDropdown>
</template>
<script setup>
const options = [
{ key: '1', label: 'Option 1', selected: true },
{ key: '2', label: 'Option 2' },
{
key: '3',
label: 'Option 3',
description: 'Additional information',
descriptionIcon: 'InfoIcon',
},
]
</script>
Tree Mode
vue
<template>
<HLDropdown id="tree-dropdown" :options="treeOptions" tree-mode :show-search="false">
<HLButton>Navigate</HLButton>
</HLDropdown>
</template>
<script setup>
const treeOptions = [
{
key: '1',
label: 'Category 1',
children: [
{ key: '1-1', label: 'Subcategory 1.1' },
{ key: '1-2', label: 'Subcategory 1.2' },
],
},
{
key: '2',
label: 'Category 2',
children: [
{ key: '2-1', label: 'Subcategory 2.1' },
{ key: '2-2', label: 'Subcategory 2.2' },
],
},
]
</script>
Best Practices
- Always provide a unique
id
prop for accessibility - Use appropriate trigger based on user interaction needs
- Consider using
treeMode
for complex hierarchical data - Enable search for dropdowns with many options
- Use descriptions and icons to provide additional context
- Keep option labels concise and clear
- Use appropriate placement based on available space
- Consider mobile responsiveness when setting width
- Implement proper event handling
- Follow accessibility guidelines
Additional Notes
- Built-in search functionality with customizable placeholder
- Support for hierarchical navigation with back button
- Enhanced styling with hover and active states
- Automatic overflow handling
- Support for custom option rendering
- Integration with other HighRise components
- RTL layout support
- Consistent styling through CSS variables
- Improved accessibility features
- Support for various content types (text, icons, avatars)