Skip to content

Commit

Permalink
fix(Dropdown): fix missing rendering of icons in selection mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Fox32 committed Mar 24, 2022
1 parent 9dd0596 commit ab1ef0a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
@@ -0,0 +1,20 @@
import React from 'react'
import { Dropdown } from 'semantic-ui-react'

const packageManagersOptions = [
{ key: 'gem', value: 'gem', icon: 'gem', text: 'RubyGems' },
{ key: 'npm', value: 'npm', icon: 'npm', text: 'NPM' },
{ key: 'docker', value: 'docker', icon: 'docker', text: 'Docker' },
]

const DropdownExampleSearchSelection = () => (
<Dropdown
placeholder='Select Package Manager'
fluid
search
selection
options={packageManagersOptions}
/>
)

export default DropdownExampleSearchSelection
9 changes: 8 additions & 1 deletion docs/src/examples/modules/Dropdown/Types/index.js
Expand Up @@ -26,7 +26,14 @@ const DropdownTypesExamples = () => (
description='A selection dropdown can allow a user to search through a large list of choices.'
examplePath='modules/Dropdown/Types/DropdownExampleSearchSelection'
/>
<ComponentExample examplePath='modules/Dropdown/Types/DropdownExampleSearchSelectionTwo' />
<ComponentExample
title='Search Selection with Text'
examplePath='modules/Dropdown/Types/DropdownExampleSearchSelectionTwo'
/>
<ComponentExample
title='Search Selection with Icon'
examplePath='modules/Dropdown/Types/DropdownExampleSearchSelectionIcon'
/>
{/* Possibly add state selection example. */}
<ComponentExample
title='Multiple Selection'
Expand Down
3 changes: 2 additions & 1 deletion src/modules/Dropdown/Dropdown.js
Expand Up @@ -39,7 +39,7 @@ const getKeyAndValues = (options) =>
options ? options.map((option) => _.pick(option, ['key', 'value'])) : options

function renderItemContent(item) {
const { flag, image, text } = item
const { flag, image, icon, text } = item

// TODO: remove this in v3
// This maintains compatibility with Shorthand API in v1 as this might be called in "Label.create()"
Expand All @@ -52,6 +52,7 @@ function renderItemContent(item) {
<>
{Flag.create(flag)}
{Image.create(image)}
{Icon.create(icon)}

{text}
</>
Expand Down

0 comments on commit ab1ef0a

Please sign in to comment.