fix(inline editor button): only show keyboard shortcut if hotkey active

This commit is contained in:
Charis Lam committed 2025-10-28 13:03:04 -04:00
1 parent 6fc1ce42cf
commit 29b3e8273c
1 file changed
+16 -5
@@ -1,10 +1,21 @@
import { ButtonTooltip } from 'components/ui/ButtonTooltip'
import { SqlEditor } from 'icons'
import { sidebarManagerState, useSidebarManagerSnapshot } from 'state/sidebar-manager-state'
import { LOCAL_STORAGE_KEYS } from 'common'
import { SIDEBAR_KEYS } from 'components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
import { ButtonTooltip } from 'components/ui/ButtonTooltip'
import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
import { SqlEditor } from 'icons'
import { useSidebarManagerSnapshot } from 'state/sidebar-manager-state'
import { cn, KeyboardShortcut } from 'ui'
export const InlineEditorButton = ({ showShortcut = true }: { showShortcut?: boolean }) => {
const InlineEditorKeyboardTooltip = () => {
const [hotkeyEnabled] = useLocalStorageQuery(
LOCAL_STORAGE_KEYS.HOTKEY_SIDEBAR(SIDEBAR_KEYS.EDITOR_PANEL),
true
)
return hotkeyEnabled ? <KeyboardShortcut keys={['Meta', 'e']} /> : null
}
export const InlineEditorButton = () => {
const { activeSidebar, toggleSidebar } = useSidebarManagerSnapshot()
const isOpen = activeSidebar?.id === SIDEBAR_KEYS.EDITOR_PANEL
@@ -27,7 +38,7 @@ export const InlineEditorButton = ({ showShortcut = true }: { showShortcut?: boo
text: (
<div className="flex items-center gap-4">
<span>SQL Editor</span>
{showShortcut && <KeyboardShortcut keys={['Meta', 'e']} />}
<InlineEditorKeyboardTooltip />
</div>
),
},