Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix(ui): ensure select value from items list
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed Sep 4, 2019
1 parent 242b2bd commit f3423d4
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions renderer/components/Form/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,30 @@ const Select = props => {
openMenu,
toggleMenu,
}) => {
/**
* getInitialValue - Get the initial selected value.
*
* @returns {string} Initial selected value.
*/
const getInitialValue = () => {
if (selectedItem) {
return selectedItem.value
}

if (initialSelectedItem) {
initialSelectedItem.value
return initialSelectedItem.value
}

return ''
}

/**
* getValue - Get the current selected value.
*
* @returns {string} Current selected value.
*/
const getValue = () => {
return selectedItem ? selectedItem.value : ''
}

return (
<div style={{ position: 'relative' }}>
{label && (
Expand All @@ -199,6 +211,7 @@ const Select = props => {
fieldApi={fieldApi}
fieldState={fieldState}
forwardedRef={inputRef}
value={getValue()}
/>
<Box>
{isOpen ? <ArrowIconOpen width={iconSize} /> : <ArrowIconClosed width={iconSize} />}
Expand Down

0 comments on commit f3423d4

Please sign in to comment.