Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: ESLint errors relating to accessibility in project settings (#50848)

ChloeGarciaMillerande0d3489c87cf
diff --git a/apps/studio/components/interfaces/Settings/API/ExposedFunctionSelector.tsx b/apps/studio/components/interfaces/Settings/API/ExposedFunctionSelector.tsx
index 9032e14a20e..ad401bccaff 100644
--- a/apps/studio/components/interfaces/Settings/API/ExposedFunctionSelector.tsx
+++ b/apps/studio/components/interfaces/Settings/API/ExposedFunctionSelector.tsx
@@ -95,30 +95,46 @@ export const ExposedFunctionSelector = ({
}
}, [entry?.isIntersecting, hasNextPage, isFetching, isFetchingNextPage, isPending, fetchNextPage])
+ let functionsSummary: string
+
+ if (isCountsPending) {
+ functionsSummary = 'Loading functions...'
+ } else if (totalCount === 0) {
+ functionsSummary = 'No functions available'
+ } else {
+ functionsSummary = `${grantsCount} of ${totalCount} functions exposed${
+ pendingCount > 0 ? `, ${pendingCount} pending ${pluralize(pendingCount, 'change')}` : ''
+ }`
+ }
+
return (
<Popover open={open} onOpenChange={setOpen} modal={false}>
- <PopoverTrigger asChild>
- <Button
- size="small"
- disabled={disabled}
- className="w-full [&>span]:w-full pr-1! space-x-1"
- iconRight={<ChevronsUpDown className="text-foreground-muted" strokeWidth={2} size={14} />}
- >
- <div className="w-full flex gap-1">
- <p className="text-foreground-lighter">
- {isCountsPending
- ? 'Loading functions...'
- : totalCount === 0
- ? 'No functions available'
- : `${grantsCount} of ${totalCount} functions exposed${
- pendingCount > 0
- ? `, ${pendingCount} pending ${pluralize(pendingCount, 'change')}`
- : ''
- }`}
- </p>
- </div>
- </Button>
- </PopoverTrigger>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <PopoverTrigger asChild>
+ <Button
+ size="small"
+ disabled={disabled}
+ className="w-full [&>span]:w-full pr-1! space-x-1"
+ iconRight={
+ <ChevronsUpDown className="text-foreground-muted" strokeWidth={2} size={14} />
+ }
+ aria-label="Select functions"
+ // Tooltip repeats the label; the description would read the name twice
+ aria-describedby={undefined}
+ >
+ <div className="w-full flex gap-1">
+ <p className="text-foreground-lighter" aria-live="polite">
+ {functionsSummary}
+ </p>
+ </div>
+ </Button>
+ </PopoverTrigger>
+ </TooltipTrigger>
+ <TooltipContent side="bottom" align="end">
+ Select functions
+ </TooltipContent>
+ </Tooltip>
<PopoverContent
className="p-0 min-w-[200px] pointer-events-auto"
side="bottom"
diff --git a/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx b/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx
index 8f4040a408b..fc7e822bdb8 100644
--- a/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx
+++ b/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx
@@ -13,6 +13,9 @@ import {
PopoverContent,
PopoverTrigger,
ScrollArea,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
} from 'ui'
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
@@ -96,23 +99,41 @@ export const ExposedSchemaSelector = ({
protectedSchemas: internalSchemasCannotExpose,
})
+ let schemasSummary: string
+
+ if (isSuccess) {
+ schemasSummary = `${selectedCount} of ${totalCount} ${pluralize(totalCount, 'schema')} exposed`
+ } else {
+ schemasSummary = 'Loading schemas...'
+ }
+
return (
<Popover open={open} onOpenChange={setOpen} modal={false}>
- <PopoverTrigger asChild>
- <Button
- size="small"
- className="w-full [&>span]:w-full pr-1! space-x-1"
- iconRight={<ChevronsUpDown className="text-foreground-muted" strokeWidth={2} size={14} />}
- >
- <div className="w-full flex gap-1">
- <p className="text-foreground-lighter">
- {isSuccess
- ? `${selectedCount} of ${totalCount} ${pluralize(totalCount, 'schema')} exposed`
- : 'Loading schemas...'}
- </p>
- </div>
- </Button>
- </PopoverTrigger>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <PopoverTrigger asChild>
+ <Button
+ size="small"
+ className="w-full [&>span]:w-full pr-1! space-x-1"
+ iconRight={
+ <ChevronsUpDown className="text-foreground-muted" strokeWidth={2} size={14} />
+ }
+ aria-label="Select schemas"
+ // Tooltip repeats the label; the description would read the name twice
+ aria-describedby={undefined}
+ >
+ <div className="w-full flex gap-1">
+ <p className="text-foreground-lighter" aria-live="polite">
+ {schemasSummary}
+ </p>
+ </div>
+ </Button>
+ </PopoverTrigger>
+ </TooltipTrigger>
+ <TooltipContent side="bottom" align="end">
+ Select schemas
+ </TooltipContent>
+ </Tooltip>
<PopoverContent
className="p-0 min-w-[200px] pointer-events-auto"
side="bottom"
diff --git a/apps/studio/components/interfaces/Settings/API/ExposedTableSelector.tsx b/apps/studio/components/interfaces/Settings/API/ExposedTableSelector.tsx
index 88d2e3dd0e6..78c5fb7e972 100644
--- a/apps/studio/components/interfaces/Settings/API/ExposedTableSelector.tsx
+++ b/apps/studio/components/interfaces/Settings/API/ExposedTableSelector.tsx
@@ -89,30 +89,46 @@ export const ExposedTableSelector = ({
}
}, [entry?.isIntersecting, hasNextPage, isFetching, isFetchingNextPage, isPending, fetchNextPage])
+ let tablesSummary: string
+
+ if (isCountsPending) {
+ tablesSummary = 'Loading tables...'
+ } else if (totalCount === 0) {
+ tablesSummary = 'No tables available'
+ } else {
+ tablesSummary = `${grantsCount} of ${totalCount} tables exposed${
+ pendingCount > 0 ? `, ${pendingCount} pending ${pluralize(pendingCount, 'change')}` : ''
+ }`
+ }
+
return (
<Popover open={open} onOpenChange={setOpen} modal={false}>
- <PopoverTrigger asChild>
- <Button
- size="small"
- disabled={disabled}
- className="w-full [&>span]:w-full pr-1! space-x-1"
- iconRight={<ChevronsUpDown className="text-foreground-muted" strokeWidth={2} size={14} />}
- >
- <div className="w-full flex gap-1">
- <p className="text-foreground-lighter">
- {isCountsPending
- ? 'Loading tables...'
- : totalCount === 0
- ? 'No tables available'
- : `${grantsCount} of ${totalCount} tables exposed${
- pendingCount > 0
- ? `, ${pendingCount} pending ${pluralize(pendingCount, 'change')}`
- : ''
- }`}
- </p>
- </div>
- </Button>
- </PopoverTrigger>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <PopoverTrigger asChild>
+ <Button
+ size="small"
+ disabled={disabled}
+ className="w-full [&>span]:w-full pr-1! space-x-1"
+ iconRight={
+ <ChevronsUpDown className="text-foreground-muted" strokeWidth={2} size={14} />
+ }
+ aria-label="Select tables"
+ // Tooltip repeats the label; the description would read the name twice
+ aria-describedby={undefined}
+ >
+ <div className="w-full flex gap-1">
+ <p className="text-foreground-lighter" aria-live="polite">
+ {tablesSummary}
+ </p>
+ </div>
+ </Button>
+ </PopoverTrigger>
+ </TooltipTrigger>
+ <TooltipContent side="bottom" align="end">
+ Select tables
+ </TooltipContent>
+ </Tooltip>
<PopoverContent
className="p-0 min-w-[200px] pointer-events-auto"
side="bottom"
diff --git a/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx b/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx
index 770317b3044..c150f1bdd19 100644
--- a/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx
+++ b/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx
@@ -512,14 +512,12 @@ export const PostgrestConfig = () => {
description="Grants privileges to Data API roles by default, exposing new tables. We recommend disabling this to control access manually."
>
<FormControl>
- <div>
- <Switch
- size="large"
- disabled={!canUpdateExposedEntities}
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </div>
+ <Switch
+ size="large"
+ disabled={!canUpdateExposedEntities}
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ />
</FormControl>
</FormItemLayout>
</FormItem>
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.tsx
index 11c57cebee4..8ff13f36b16 100644
--- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.tsx
+++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.tsx
@@ -3,7 +3,7 @@ import { useParams } from 'common'
import { partition } from 'lodash'
import { Globe2, Loader2, Network } from 'lucide-react'
import { useEffect, useMemo, useState } from 'react'
-import { Button, FloatingPlate } from 'ui'
+import { Button, FloatingPlate, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
import { DiagramFlow } from './DiagramFlow'
import { SmoothstepEdge } from './Edge'
@@ -180,20 +180,40 @@ const InstanceConfigurationUI = () => {
<FloatingPlate className="z-10 absolute top-4 right-4 items-center justify-center gap-x-2">
{isAws && (
<div className="flex items-center justify-center">
- <Button
- icon={<Network size={15} />}
- className={`rounded-r-none transition ${
- view === 'flow' ? 'opacity-100' : 'opacity-50'
- }`}
- onClick={() => setView('flow')}
- />
- <Button
- icon={<Globe2 size={15} />}
- className={`rounded-l-none transition ${
- view === 'map' ? 'opacity-100' : 'opacity-50'
- }`}
- onClick={() => setView('map')}
- />
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ icon={<Network size={15} />}
+ className={`rounded-r-none transition motion-reduce:transition-none ${
+ view === 'flow' ? 'opacity-100' : 'opacity-50'
+ }`}
+ onClick={() => setView('flow')}
+ aria-label="Show infrastructure as a diagram"
+ aria-pressed={view === 'flow'}
+ // Tooltip repeats the label; screen readers would read it twice
+ aria-describedby={undefined}
+ />
+ </TooltipTrigger>
+ <TooltipContent side="bottom">
+ Show infrastructure as a diagram
+ </TooltipContent>
+ </Tooltip>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ icon={<Globe2 size={15} />}
+ className={`rounded-l-none transition motion-reduce:transition-none ${
+ view === 'map' ? 'opacity-100' : 'opacity-50'
+ }`}
+ onClick={() => setView('map')}
+ aria-label="Show infrastructure on the map"
+ aria-pressed={view === 'map'}
+ // Tooltip repeats the label; screen readers would read it twice
+ aria-describedby={undefined}
+ />
+ </TooltipTrigger>
+ <TooltipContent side="bottom">Show infrastructure on the map</TooltipContent>
+ </Tooltip>
</div>
)}
</FloatingPlate>