fix(sqllab): invalid empty state on switch tab (#29278)

This commit is contained in:
JUST.in DO IT
2024-06-18 11:45:09 -07:00
committed by GitHub
parent 527f1d20ad
commit 725afc3848
3 changed files with 6 additions and 19 deletions

View File

@@ -303,7 +303,10 @@ const SqlEditor: FC<Props> = ({
);
const [showCreateAsModal, setShowCreateAsModal] = useState(false);
const [createAs, setCreateAs] = useState('');
const [showEmptyState, setShowEmptyState] = useState(false);
const showEmptyState = useMemo(
() => !database || isEmpty(database),
[database],
);
const sqlEditorRef = useRef<HTMLDivElement>(null);
const northPaneRef = useRef<HTMLDivElement>(null);
@@ -562,12 +565,6 @@ const SqlEditor: FC<Props> = ({
// TODO: Remove useEffectEvent deps once https://github.com/facebook/react/pull/25881 is released
}, [onBeforeUnload, loadQueryEditor, isActive]);
useEffect(() => {
if (!database || isEmpty(database)) {
setShowEmptyState(true);
}
}, [database]);
useEffect(() => {
// setup hotkeys
const hotkeys = getHotkeyConfig();
@@ -911,7 +908,6 @@ const SqlEditor: FC<Props> = ({
<SqlEditorLeftBar
database={database}
queryEditorId={queryEditor.id}
setEmptyState={bool => setShowEmptyState(bool)}
/>
</StyledSidebar>
)}