mirror of
https://github.com/apache/superset.git
synced 2026-06-01 05:39:17 +00:00
fix: Verify when null value should be undefined in Select (#17013)
* Check for null value * Safety chek SelectControl and SelectAsyncControl
This commit is contained in:
@@ -71,6 +71,17 @@ const SelectAsyncControl = ({
|
||||
onChange(onChangeVal);
|
||||
};
|
||||
|
||||
const getValue = () => {
|
||||
const currentValue =
|
||||
value || (props.default !== undefined ? props.default : undefined);
|
||||
|
||||
// safety check - the value is intended to be undefined but null was used
|
||||
if (currentValue === null && !options.find(o => o.value === null)) {
|
||||
return undefined;
|
||||
}
|
||||
return currentValue;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const onError = (response: Response) =>
|
||||
getClientErrorObject(response).then(e => {
|
||||
@@ -93,7 +104,7 @@ const SelectAsyncControl = ({
|
||||
<Select
|
||||
allowClear={allowClear}
|
||||
ariaLabel={ariaLabel || t('Select ...')}
|
||||
value={value || (props.default !== undefined ? props.default : undefined)}
|
||||
value={getValue()}
|
||||
header={<ControlHeader {...props} />}
|
||||
mode={multi ? 'multiple' : 'single'}
|
||||
onChange={handleOnChange}
|
||||
|
||||
Reference in New Issue
Block a user