Skip to content

Commit

Permalink
fix(sqllab): Fix autocomplete for SQL Lab (#22329)
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio-RiveroMartnez authored Dec 5, 2022
1 parent 5e1b817 commit 96de314
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ test('should toggle the table when the header is clicked', async () => {
userEvent.click(header);

await waitFor(() => {
expect(store.getActions()).toHaveLength(2);
expect(store.getActions()[1].type).toEqual('COLLAPSE_TABLE');
expect(store.getActions()).toHaveLength(4);
expect(store.getActions()[3].type).toEqual('COLLAPSE_TABLE');
});
});

Expand Down
11 changes: 9 additions & 2 deletions superset-frontend/src/components/TableSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ const TableSelector: FunctionComponent<TableSelectorProps> = ({
} = useTables({
dbId: database?.id,
schema: currentSchema,
onSuccess: (data: { options: Table[] }) => {
onTablesLoad?.(data.options);
onSuccess: () => {
if (isFetched) {
addSuccessToast(t('List updated'));
}
Expand All @@ -203,6 +202,14 @@ const TableSelector: FunctionComponent<TableSelectorProps> = ({
},
});

useEffect(() => {
// Set the tableOptions in the queryEditor so autocomplete
// works on new tabs
if (data && isFetched) {
onTablesLoad?.(data.options);
}
}, [data, isFetched, onTablesLoad]);

const tableOptions = useMemo<TableOption[]>(
() =>
data
Expand Down

0 comments on commit 96de314

Please sign in to comment.