Skip to content

Commit

Permalink
fix: Filtering db names while creating dataset is not working (apache…
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina authored and Emmanuel Bavoux committed Nov 14, 2021
1 parent 2ab54a2 commit c345cd2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ export default function DatabaseSelector({
return renderSelectRow(
<Select
ariaLabel={t('Select database or type database name')}
optionFilterProps={['database_name', 'value']}
data-test="select-database"
header={<FormLabel>{t('Database')}</FormLabel>}
lazyLoading={false}
Expand Down
24 changes: 14 additions & 10 deletions superset-frontend/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ const Select = ({
mode = 'single',
name,
notFoundContent,
onError,
onChange,
onClear,
optionFilterProps = ['label', 'value'],
Expand Down Expand Up @@ -328,15 +329,18 @@ const Select = ({
setSearchedValue('');
};

const onError = (response: Response) =>
getClientErrorObject(response).then(e => {
const { error } = e;
setError(error);
const internalOnError = useCallback(
(response: Response) =>
getClientErrorObject(response).then(e => {
const { error } = e;
setError(error);

if (props.onError) {
props.onError(error);
}
});
if (onError) {
onError(error);
}
}),
[onError],
);

const handleData = (data: OptionsType) => {
let mergedData: OptionsType = [];
Expand Down Expand Up @@ -391,13 +395,13 @@ const Select = ({
setAllValuesLoaded(true);
}
})
.catch(onError)
.catch(internalOnError)
.finally(() => {
setIsLoading(false);
setIsTyping(false);
});
},
[allValuesLoaded, fetchOnlyOnSearch, options],
[allValuesLoaded, fetchOnlyOnSearch, internalOnError, options],
);

const handleOnSearch = useMemo(
Expand Down

0 comments on commit c345cd2

Please sign in to comment.