diff --git a/superset-frontend/src/SqlLab/components/SqlEditorLeftBar.jsx b/superset-frontend/src/SqlLab/components/SqlEditorLeftBar.jsx
index c4751a1aeeb21..32c02de745366 100644
--- a/superset-frontend/src/SqlLab/components/SqlEditorLeftBar.jsx
+++ b/superset-frontend/src/SqlLab/components/SqlEditorLeftBar.jsx
@@ -142,6 +142,7 @@ export default class SqlEditorLeftBar extends React.PureComponent {
schema={qe.schema}
sqlLabMode
tableNameSticky={false}
+ useDocumentBody
/>
diff --git a/superset-frontend/src/components/DatabaseSelector/index.tsx b/superset-frontend/src/components/DatabaseSelector/index.tsx
index 34060bc5faaea..15a08fb2b9491 100644
--- a/superset-frontend/src/components/DatabaseSelector/index.tsx
+++ b/superset-frontend/src/components/DatabaseSelector/index.tsx
@@ -72,6 +72,7 @@ interface DatabaseSelectorProps {
readOnly?: boolean;
schema?: string;
sqlLabMode?: boolean;
+ useDocumentBody?: boolean;
onChange?: ({
dbId,
schema,
@@ -96,6 +97,7 @@ export default function DatabaseSelector({
readOnly = false,
schema,
sqlLabMode = false,
+ useDocumentBody = false,
}: DatabaseSelectorProps) {
const [currentDbId, setCurrentDbId] = useState(dbId);
const [currentSchema, setCurrentSchema] = useState(
@@ -103,7 +105,7 @@ export default function DatabaseSelector({
);
const [schemaLoading, setSchemaLoading] = useState(false);
const [schemaOptions, setSchemaOptions] = useState([]);
-
+ let TableRef: HTMLElement;
function fetchSchemas(databaseId: number, forceRefresh = false) {
const actualDbId = databaseId || dbId;
if (actualDbId) {
@@ -246,6 +248,7 @@ export default function DatabaseSelector({
autoSelect
isDisabled={!isDatabaseSelectEnabled || readOnly}
menuPosition="fixed"
+ menuPortalTarget={useDocumentBody ? document.body : TableRef}
/>,
null,
);
diff --git a/superset-frontend/src/components/TableSelector/index.tsx b/superset-frontend/src/components/TableSelector/index.tsx
index c89ee693160f7..e8ecf3e69dea1 100644
--- a/superset-frontend/src/components/TableSelector/index.tsx
+++ b/superset-frontend/src/components/TableSelector/index.tsx
@@ -104,6 +104,7 @@ interface TableSelectorProps {
sqlLabMode?: boolean;
tableName?: string;
tableNameSticky?: boolean;
+ useDocumentBody?: boolean;
}
const TableSelector: FunctionComponent = ({
@@ -124,6 +125,7 @@ const TableSelector: FunctionComponent = ({
sqlLabMode = true,
tableName,
tableNameSticky = true,
+ useDocumentBody = false,
}) => {
const [currentSchema, setCurrentSchema] = useState(
schema,
@@ -133,7 +135,7 @@ const TableSelector: FunctionComponent = ({
);
const [tableLoading, setTableLoading] = useState(false);
const [tableOptions, setTableOptions] = useState([]);
-
+ let TableRef: HTMLElement;
function fetchTables(
databaseId?: number,
schema?: string,
@@ -303,6 +305,7 @@ const TableSelector: FunctionComponent = ({
sqlLabMode={sqlLabMode}
isDatabaseSelectEnabled={isDatabaseSelectEnabled && !readOnly}
readOnly={readOnly}
+ useDocumentBody={useDocumentBody}
/>
);
}
@@ -317,6 +320,7 @@ const TableSelector: FunctionComponent = ({
name="select-table"
isLoading={tableLoading}
ignoreAccents={false}
+ menuShouldScrollIntoView={false}
placeholder={t('Select table or type table name')}
autosize={false}
onChange={changeTable}
@@ -327,6 +331,10 @@ const TableSelector: FunctionComponent = ({
valueRenderer={renderTableOption}
isDisabled={readOnly}
menuPosition="fixed"
+ menuPortalTarget={useDocumentBody ? document.body : TableRef}
+ styles={{
+ menuPortal: base => ({ ...base, zIndex: 9999 }),
+ }}
/>
);
} else if (formMode) {