mirror of
https://github.com/supabase/supabase.git
synced 2026-06-14 23:25:16 +08:00
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
24 lines
810 B
TypeScript
24 lines
810 B
TypeScript
import { useCallback } from 'react'
|
|
|
|
import { useMobileSheet } from '../NavigationBar/MobileSheetContext'
|
|
import { useSidebarManagerSnapshot } from '@/state/sidebar-manager-state'
|
|
|
|
export function useFloatingToolbarSidebarClick() {
|
|
const { setContent: setSheetContent } = useMobileSheet()
|
|
const { activeSidebar, openSidebar } = useSidebarManagerSnapshot()
|
|
|
|
return useCallback(
|
|
(e: React.MouseEvent) => {
|
|
const target = (e.target as HTMLElement).closest?.('[data-sidebar-id]')
|
|
const sidebarId = target?.getAttribute('data-sidebar-id')
|
|
if (sidebarId && activeSidebar?.id !== sidebarId) {
|
|
e.preventDefault()
|
|
e.stopPropagation()
|
|
openSidebar(sidebarId)
|
|
setSheetContent(sidebarId)
|
|
}
|
|
},
|
|
[activeSidebar?.id, openSidebar, setSheetContent]
|
|
)
|
|
}
|