Skip to content

Commit

Permalink
fix: fix select field value not applied on native mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dackmin committed Dec 6, 2018
1 parent 69456ed commit d0a9089
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/SelectField.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class SelectField extends React.Component {
);

if (native && !autoComplete) {
this.onNativeChange(index);
this.onNativeChange(null, index);
} else {
this.onChange(options[index]);
}
Expand Down Expand Up @@ -137,14 +137,18 @@ class SelectField extends React.Component {
});
}

onNativeChange(e) {
onNativeChange(e, forceIndex) {
const { validate, parseValue, options, disabled } = this.props;

if (disabled) {
return;
}

const option = options[e?.target?.value || -1];
const index = typeof forceIndex !== 'undefined' && forceIndex !== null
? forceIndex
: e?.target?.value;

const option = options[index];
const value = option ? parseValue(option) : null;
const valid = validate(value);

Expand Down

0 comments on commit d0a9089

Please sign in to comment.