Skip to content

Update the DropdownMenu to set the selected item #2188

@flacial

Description

@flacial

Related to #1975

Update the DropdownMenu component to set the selected item as the active one or Dropdown.Toggle child.

Example code:

export const DropdownMenu: React.FC<DropDownMenuProps> = ({ items, title }) => {
  const [activeItem, setActiveItem] = useState({
    name: title
  })

  return (
    <Dropdown>
      <Dropdown.Toggle bsPrefix={styles.dropdown} id="dropdown-lesson">
        // Here is the solution
        {activeItem.name || 'None'}
        <ChevronRight />
      </Dropdown.Toggle>
  )
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions