From d0a9089d451734f1b3a48e2237ac5fce875ef96f Mon Sep 17 00:00:00 2001 From: Ugo Stephant Date: Thu, 6 Dec 2018 21:58:52 +0100 Subject: [PATCH] fix: fix select field value not applied on native mode --- src/components/SelectField.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/SelectField.js b/src/components/SelectField.js index 9047dbf26..db1fab91b 100644 --- a/src/components/SelectField.js +++ b/src/components/SelectField.js @@ -108,7 +108,7 @@ class SelectField extends React.Component { ); if (native && !autoComplete) { - this.onNativeChange(index); + this.onNativeChange(null, index); } else { this.onChange(options[index]); } @@ -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);