Skip to content

Commit

Permalink
select-vision: fix state when none vision is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
macabeus committed Jun 9, 2019
1 parent 7c76399 commit b926a5f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions brush/src/components/SelectVision/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,29 @@ import ROMContext from '../../context/ROMContext'

const SelectVision = () => {
const { romBufferMemory } = useContext(ROMContext)
const { updateVision, visionIndex, visionWorld } = useContext(VisionContext)
const {
updateVision,
vision: { state: visionState },
visionIndex,
visionWorld,
} = useContext(VisionContext)

const setNewVision = (newVision) => {
const [newVisionWorld, newVisionIndex] = newVision.split('-')

updateVision(romBufferMemory, newVisionWorld, newVisionIndex)
}

const dropdownValue = visionState === 'noSelected' ?
'' :
`${visionWorld}-${visionIndex}`

return (
<Dropdown
name="selectVision"
placeholder="Select a vision"
onChange={e => setNewVision(e.target.value)}
value={`${visionWorld}-${visionIndex}`}
value={dropdownValue}
options={[{ name: 'Vision 1-1', value: '1-1' }, { name: 'Vision 1-2', value: '1-2' }]}
/>
)
Expand Down

0 comments on commit b926a5f

Please sign in to comment.