This is an automated email from the ASF dual-hosted git repository.

diegopucci pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 66b0877  Strict undefined check SelectControl (#17008)
66b0877 is described below

commit 66b0877445600ca6bbed70320d4c4a54f739912f
Author: Geido <[email protected]>
AuthorDate: Thu Oct 7 17:22:52 2021 +0300

    Strict undefined check SelectControl (#17008)
---
 superset-frontend/src/components/Select/Select.tsx                  | 2 +-
 superset-frontend/src/explore/components/controls/SelectControl.jsx | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/superset-frontend/src/components/Select/Select.tsx 
b/superset-frontend/src/components/Select/Select.tsx
index c5c53a6..05f43eb 100644
--- a/superset-frontend/src/components/Select/Select.tsx
+++ b/superset-frontend/src/components/Select/Select.tsx
@@ -627,7 +627,7 @@ const Select = ({
           selectOptions.map(opt => {
             const isOptObject = typeof opt === 'object';
             const label = isOptObject ? opt?.label || opt.value : opt;
-            const value = (isOptObject && opt.value) || opt;
+            const value = isOptObject ? opt.value : opt;
             const { customLabel, ...optProps } = opt;
 
             return (
diff --git 
a/superset-frontend/src/explore/components/controls/SelectControl.jsx 
b/superset-frontend/src/explore/components/controls/SelectControl.jsx
index 4342485..4d59808 100644
--- a/superset-frontend/src/explore/components/controls/SelectControl.jsx
+++ b/superset-frontend/src/explore/components/controls/SelectControl.jsx
@@ -110,10 +110,12 @@ export default class SelectControl extends 
React.PureComponent {
     let onChangeVal = val;
 
     if (Array.isArray(val)) {
-      const values = val.map(v => v?.[valueKey] || v);
+      const values = val.map(v =>
+        v?.[valueKey] !== undefined ? v[valueKey] : v,
+      );
       onChangeVal = values;
     }
-    if (typeof val === 'object' && val?.[valueKey]) {
+    if (typeof val === 'object' && val?.[valueKey] !== undefined) {
       onChangeVal = val[valueKey];
     }
     this.props.onChange(onChangeVal, []);

Reply via email to