update selected to value in AnsibleSelect

This commit is contained in:
John Mitchell
2019-02-13 14:52:11 -05:00
parent de658939c5
commit 35c94e9cd8
2 changed files with 12 additions and 6 deletions

View File

@@ -26,18 +26,19 @@ class AnsibleSelect extends React.Component {
}
onSelectChange (val, event) {
const { onChange } = this.props;
const { onChange, name } = this.props;
event.target.name = name;
onChange(val, event);
}
render () {
const { count } = this.state;
const { labelName, selected, data, fieldId } = this.props;
const { labelName, value, data, fieldId } = this.props;
let elem;
if (count > 1) {
elem = (
<FormGroup label={labelName} fieldId={fieldId || 'ansible-select'}>
<Select value={selected} id={`select-${fieldId}` || 'ansible-select-element'} onChange={this.onSelectChange} aria-label="Select Input">
<Select value={value} id={`select-${fieldId}` || 'ansible-select-element'} onChange={this.onSelectChange} aria-label="Select Input">
{data.map((datum) => (
<SelectOption isDisabled={datum.disabled} key={datum} value={datum} label={datum} />
))}