Files
supabase/apps/studio/components/layouts/AppLayout/InlineEditorButton.tsx
ChloeGarciaMillerand 2c48c6a002 fix: improve accessibility for icon buttons in LayoutHeader (#45790)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Bug fix (accessibility improvement in LayoutHeader)

## What is the current behavior?

Icon-only buttons do not have explicit accessible names for screen
readers.

## What is the new behavior?

All icon-only buttons now have explicit accessible names using visually
hidden text (sr-only), ensuring proper screen reader support.

## Additional context

Tooltip text is preserved for visual users.
No visual changes were introduced.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Accessibility**
* Added hidden screen-reader labels to multiple toolbar and menu buttons
(Settings, Advisor Center, AI Assistant, SQL Editor, Help) so icons are
announced by assistive technologies, improving navigation and
discoverability across the studio interface.

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/45790)
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Gildas Garcia <1122076+djhi@users.noreply.github.com>
2026-05-11 17:30:16 +02:00

54 lines
1.8 KiB
TypeScript

import { SqlEditor } from 'icons'
import { cn, KeyboardShortcut } from 'ui'
import { SIDEBAR_KEYS } from '@/components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { useTrack } from '@/lib/telemetry/track'
import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
import { useIsShortcutEnabled } from '@/state/shortcuts/useIsShortcutEnabled'
import { useSidebarManagerSnapshot } from '@/state/sidebar-manager-state'
const InlineEditorKeyboardTooltip = () => {
const hotkeyEnabled = useIsShortcutEnabled(SHORTCUT_IDS.INLINE_EDITOR_TOGGLE)
return hotkeyEnabled ? <KeyboardShortcut keys={['Meta', 'E']} /> : null
}
export const InlineEditorButton = () => {
const { activeSidebar, toggleSidebar } = useSidebarManagerSnapshot()
const isOpen = activeSidebar?.id === SIDEBAR_KEYS.EDITOR_PANEL
const track = useTrack()
const handleClick = () => {
track('header_inline_editor_button_clicked')
toggleSidebar(SIDEBAR_KEYS.EDITOR_PANEL)
}
return (
<ButtonTooltip
type="outline"
size="tiny"
id="editor-trigger"
className={cn(
'rounded-full w-[32px] h-[32px] flex items-center justify-center p-0 text-foreground-light hover:text-foreground',
isOpen && 'bg-foreground text-background hover:text-background'
)}
onClick={handleClick}
tooltip={{
content: {
className: 'p-1 pl-2.5',
text: (
<div className="flex items-center gap-2.5">
<span>SQL Editor</span>
<InlineEditorKeyboardTooltip />
</div>
),
},
}}
>
<SqlEditor size={16} strokeWidth={1.5} />
<span className="sr-only">SQL Editor</span>
</ButtonTooltip>
)
}