Skip to content

Commit

Permalink
fix: add prop selected to renderOption
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkrulltott committed Jul 10, 2020
1 parent 1f07266 commit 4a61df0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions packages/widgets/src/Transfer/Transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ export const Transfer = ({
toggleHighlightedSourceOption
),
highlighted,
selected: false,
})}
</Fragment>
)
Expand Down Expand Up @@ -314,6 +315,7 @@ export const Transfer = ({
toggleHighlightedPickedOption
),
highlighted,
selected: true,
})}
</Fragment>
)
Expand Down
14 changes: 10 additions & 4 deletions packages/widgets/src/Transfer/Transfer.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,13 @@ export const Filtered = () => (
</StatefulWrapper>
)

const renderOption = ({ label, value, onClick, highlighted }) => (
const renderOption = ({ label, value, onClick, highlighted, selected }) => (
<p
onClick={event => onClick({ label, value }, event)}
style={{ background: highlighted ? 'green' : 'blue' }}
style={{
background: highlighted ? 'green' : 'blue',
color: selected ? 'orange' : 'white',
}}
>
Custom: {label} (label), {value} (value)
</p>
Expand All @@ -189,10 +192,13 @@ export const CustomListOptions = () => (
<>
<strong>Custom option code:</strong>
<code>
<pre>{`const renderOption = ({ label, value, onClick, highlighted }) => (
<pre>{`const renderOption = ({ label, value, onClick, highlighted, selected }) => (
<p
onClick={event => onClick({ label, value }, event)}
style={{ background: highlighted ? 'green' : 'blue' }}
style={{
background: highlighted ? 'green' : 'blue',
color: selected ? 'orange' : 'white',
}}
>
Custom: {label} (label), {value} (value)
</p>
Expand Down

0 comments on commit 4a61df0

Please sign in to comment.