Make sure preselected value is active

[PREMIUM-59]
This commit is contained in:
Pavel Dohnal
2018-02-26 14:04:42 +00:00
parent 17e13c0956
commit 8cd83575f2

View File

@@ -227,6 +227,7 @@ define([
}, },
render: function () { render: function () {
const items = this.getItems(this.props.field); const items = this.getItems(this.props.field);
const selectedValues = this.getSelectedValues();
const options = items.map((item, index) => { const options = items.map((item, index) => {
const label = this.getLabel(item); const label = this.getLabel(item);
const searchLabel = this.getSearchLabel(item); const searchLabel = this.getSearchLabel(item);
@@ -238,6 +239,7 @@ define([
className="default" className="default"
value={value} value={value}
title={searchLabel} title={searchLabel}
selected={value === selectedValues}
> >
{ label } { label }
</option> </option>
@@ -251,7 +253,7 @@ define([
disabled={this.props.field.disabled} disabled={this.props.field.disabled}
data-placeholder={this.props.field.placeholder} data-placeholder={this.props.field.placeholder}
multiple={this.props.field.multiple} multiple={this.props.field.multiple}
defaultValue={this.getSelectedValues()} defaultValue={selectedValues}
{...this.props.field.validation} {...this.props.field.validation}
> >
{ this.insertEmptyOption() } { this.insertEmptyOption() }