From fc8234e0e970e5668425815430de98e3b169fa70 Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" Date: Thu, 20 Apr 2023 13:44:12 -0300 Subject: [PATCH 1/3] fix: Make sure the DeprecatedSelect label is always a string --- .../src/components/DeprecatedSelect/DeprecatedSelect.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/src/components/DeprecatedSelect/DeprecatedSelect.tsx b/superset-frontend/src/components/DeprecatedSelect/DeprecatedSelect.tsx index 2e2c1e9546f4..12b4b3a4dbe6 100644 --- a/superset-frontend/src/components/DeprecatedSelect/DeprecatedSelect.tsx +++ b/superset-frontend/src/components/DeprecatedSelect/DeprecatedSelect.tsx @@ -167,7 +167,7 @@ function styled< getOptionLabel = option => typeof option === 'string' ? option - : option[labelKey] || option[valueKey], + : String(option[labelKey]) || String(option[valueKey]), formatOptionLabel = ( option: OptionType, From a1d85bc0da4109909edbab7cc419093c549575a5 Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" Date: Thu, 20 Apr 2023 14:13:34 -0300 Subject: [PATCH 2/3] Returns empty --- .../src/components/DeprecatedSelect/DeprecatedSelect.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/superset-frontend/src/components/DeprecatedSelect/DeprecatedSelect.tsx b/superset-frontend/src/components/DeprecatedSelect/DeprecatedSelect.tsx index 12b4b3a4dbe6..e19a941b6d19 100644 --- a/superset-frontend/src/components/DeprecatedSelect/DeprecatedSelect.tsx +++ b/superset-frontend/src/components/DeprecatedSelect/DeprecatedSelect.tsx @@ -161,13 +161,15 @@ function styled< filterOption, ignoreAccents = false, // default is `true`, but it is slow + asText = (value: any) => (value ? String(value) : ''), + getOptionValue = option => typeof option === 'string' ? option : option[valueKey], getOptionLabel = option => typeof option === 'string' ? option - : String(option[labelKey]) || String(option[valueKey]), + : asText(option[labelKey]) || asText(option[valueKey]), formatOptionLabel = ( option: OptionType, From d6d4c3a74e274f725b3f787fff966e41bf78a00e Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" <70410625+michael-s-molina@users.noreply.github.com> Date: Thu, 20 Apr 2023 14:39:49 -0300 Subject: [PATCH 3/3] Uses the nullish coalescing operator Co-authored-by: JUST.in DO IT --- .../src/components/DeprecatedSelect/DeprecatedSelect.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/src/components/DeprecatedSelect/DeprecatedSelect.tsx b/superset-frontend/src/components/DeprecatedSelect/DeprecatedSelect.tsx index e19a941b6d19..185829b23a5d 100644 --- a/superset-frontend/src/components/DeprecatedSelect/DeprecatedSelect.tsx +++ b/superset-frontend/src/components/DeprecatedSelect/DeprecatedSelect.tsx @@ -161,7 +161,7 @@ function styled< filterOption, ignoreAccents = false, // default is `true`, but it is slow - asText = (value: any) => (value ? String(value) : ''), + asText = (value: any) => String(value ?? ''), getOptionValue = option => typeof option === 'string' ? option : option[valueKey],