Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sqllab): Fix autocomplete for SQL Lab #22329

Merged
merged 2 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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