mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Context We've been seeing many `NotFoundError: Failed to execute 'removeChild' on 'Node'` and `NotFoundError: Failed to execute 'insertBefore' on 'Node'` events on Sentry which are historically known to be caused by Google Translate in the browser. There's technically no _right way_ to address this unfortunately, but one of the solutions which should address most of these issues is to wrap any dynamic text within a span - we've considered that quite a while back tbh but never took the time to do this until today with the help of Claude. Although just a heads up that it might not necessarily completely eradicate those issues. Also added an eslint rule which should prevent future occurences of this <img width="1264" height="192" alt="image" src="https://github.com/user-attachments/assets/b2c32ea0-45a2-4ccd-82fe-1a859905fc29" />
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
import { useBreakpoint } from 'common'
|
|
import { PanelLeftCloseIcon, PanelLeftOpenIcon } from 'lucide-react'
|
|
import { cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
|
|
|
|
import { useAppStateSnapshot } from '@/state/app-state'
|
|
|
|
export function CollapseButton({ hideTabs }: { hideTabs: boolean }) {
|
|
const { showSidebar, setShowSidebar, mobileMenuOpen, setMobileMenuOpen } = useAppStateSnapshot()
|
|
const isMobile = useBreakpoint('md')
|
|
|
|
const handleToggle = () => {
|
|
if (isMobile) {
|
|
setMobileMenuOpen(!mobileMenuOpen)
|
|
} else {
|
|
setShowSidebar(!showSidebar)
|
|
}
|
|
}
|
|
|
|
return (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<button
|
|
tabIndex={0}
|
|
className={cn(
|
|
'hidden md:flex items-center justify-center w-10 h-(--header-height) hover:bg-surface-100 shrink-0',
|
|
!hideTabs && 'border-b border-b-default'
|
|
)}
|
|
onClick={handleToggle}
|
|
>
|
|
{showSidebar ? (
|
|
<>
|
|
<PanelLeftCloseIcon
|
|
size={16}
|
|
strokeWidth={1.5}
|
|
className="text-foreground-lighter hover:text-foreground-light"
|
|
/>
|
|
<span className="sr-only">Collapse sidebar</span>
|
|
</>
|
|
) : (
|
|
<>
|
|
<PanelLeftOpenIcon
|
|
size={16}
|
|
strokeWidth={1.5}
|
|
className="text-foreground-lighter hover:text-foreground-light"
|
|
/>
|
|
<span className="sr-only">Expand sidebar</span>
|
|
</>
|
|
)}
|
|
</button>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="bottom">
|
|
{showSidebar ? <span>Collapse</span> : <span>Expand</span>} <span>sidebar</span>
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
)
|
|
}
|