Skip to content

Commit

Permalink
Strict undefined check SelectControl (#17008)
Browse files Browse the repository at this point in the history
  • Loading branch information
geido authored Oct 7, 2021
1 parent 45908ff commit 66b0877
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion superset-frontend/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, []);
Expand Down

0 comments on commit 66b0877

Please sign in to comment.