Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
♿️ Add accessible names to icon-only buttons (WCAG 1.1.1 / 4.1.2) (#2497)
Luke Vella1058bb329bf8
diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.jsonindex bf582e4d0..8124a541e 100644--- a/apps/web/public/locales/en/app.json+++ b/apps/web/public/locales/en/app.json@@ -7,6 +7,7 @@"acceptInviteTitle": "{inviterName} invited you to join {spaceName}","accessDenied": "Access Denied","account": "Account",+ "accountMenu": "Account menu","accountNotLinkedDescription": "A user with this email already exists. Please log in using the original method.","actionErrorForbidden": "You are not allowed to perform this action","actionErrorInternalServerError": "An internal server error occurred",@@ -21,6 +22,7 @@"addComment": "Add Comment","addDescription": "Add description","addLicenseKey": "Add license key",+ "addParticipant": "Add participant","address": "Address","addressPlaceholder": "123 Main Street","addSeats": "{count, plural, one {Add # Seat} other {Add # Seats}}",@@ -125,6 +127,7 @@"controlPanel": "Control Panel","copied": "Copied","copiedToClipboard": "Copied to clipboard",+ "copy": "Copy","copyLink": "Copy Link","create": "Create","createApiKey": "Create API key",@@ -392,6 +395,7 @@"mixedOptionsKeepTimes": "Keep time options","mixedOptionsTitle": "Wait a minute… 🤔","monthView": "Month view",+ "moreOptions": "More options","moreParticipants": "{count, plural, other {# more…}}","muteNotifications": "Mute notifications","name": "Name",@@ -524,6 +528,7 @@"removeMemberLoading": "Removing member...","removeMemberSuccess": "Member removed successfully","removeSeats": "{count, plural, one {Remove # Seat} other {Remove # Seats}}",+ "removeTimeSlot": "Remove time slot","reopenPoll": "Reopen Poll","requiredField": "Required","requiredString": "“{name}” is required",diff --git a/apps/web/src/app/[locale]/(space)/settings/api-keys/components/create-api-key-button.tsx b/apps/web/src/app/[locale]/(space)/settings/api-keys/components/create-api-key-button.tsxindex a9e1db9a6..19d2d7495 100644--- a/apps/web/src/app/[locale]/(space)/settings/api-keys/components/create-api-key-button.tsx+++ b/apps/web/src/app/[locale]/(space)/settings/api-keys/components/create-api-key-button.tsx@@ -116,6 +116,7 @@ export function CreateApiKeyButton() {className="font-mono text-sm"/><Button+ aria-label={t("copy", { defaultValue: "Copy" })}variant="ghost"size="icon"onClick={handleCopy}diff --git a/apps/web/src/app/[locale]/(space)/settings/api-keys/components/revoke-api-key-button.tsx b/apps/web/src/app/[locale]/(space)/settings/api-keys/components/revoke-api-key-button.tsxindex 0a0432ec9..a377d23af 100644--- a/apps/web/src/app/[locale]/(space)/settings/api-keys/components/revoke-api-key-button.tsx+++ b/apps/web/src/app/[locale]/(space)/settings/api-keys/components/revoke-api-key-button.tsx@@ -39,7 +39,11 @@ export function RevokeApiKeyButton({<><DropdownMenu><DropdownMenuTrigger asChild>- <Button variant="ghost" size="icon">+ <Button+ aria-label={t("moreOptions", { defaultValue: "More options" })}+ variant="ghost"+ size="icon"+ ><Icon><MoreVerticalIcon /></Icon>diff --git a/apps/web/src/app/[locale]/(space)/settings/calendars/components/calendar-connection-list.tsx b/apps/web/src/app/[locale]/(space)/settings/calendars/components/calendar-connection-list.tsxindex d1d15d1b8..38cb97f97 100644--- a/apps/web/src/app/[locale]/(space)/settings/calendars/components/calendar-connection-list.tsx+++ b/apps/web/src/app/[locale]/(space)/settings/calendars/components/calendar-connection-list.tsx@@ -69,6 +69,9 @@ export function CalendarConnectionList() {<Tooltip><TooltipTrigger asChild><Button+ aria-label={t("syncCalendar", {+ defaultValue: "Sync calendar",+ })}loading={syncCalendar.isPending}variant="ghost"size="icon"@@ -101,7 +104,13 @@ export function CalendarConnectionList() {</Tooltip><DropdownMenu><DropdownMenuTrigger asChild>- <Button variant="ghost" size="icon">+ <Button+ aria-label={t("moreOptions", {+ defaultValue: "More options",+ })}+ variant="ghost"+ size="icon"+ ><Icon><MoreVerticalIcon /></Icon>diff --git a/apps/web/src/app/[locale]/(space)/settings/members/components/invite-dropdown-menu.tsx b/apps/web/src/app/[locale]/(space)/settings/members/components/invite-dropdown-menu.tsxindex 0d3c108d1..7dfd9ed97 100644--- a/apps/web/src/app/[locale]/(space)/settings/members/components/invite-dropdown-menu.tsx+++ b/apps/web/src/app/[locale]/(space)/settings/members/components/invite-dropdown-menu.tsx@@ -45,7 +45,11 @@ export function InviteDropdownMenu({ invite }: { invite: SpaceMemberInvite }) {<><DropdownMenu><DropdownMenuTrigger asChild>- <Button variant="ghost" size="icon">+ <Button+ aria-label={t("moreOptions", { defaultValue: "More options" })}+ variant="ghost"+ size="icon"+ ><Icon><MoreVerticalIcon /></Icon>diff --git a/apps/web/src/app/[locale]/(space)/settings/members/components/member-dropdown-menu.tsx b/apps/web/src/app/[locale]/(space)/settings/members/components/member-dropdown-menu.tsxindex f2d6c09fc..001d00c0f 100644--- a/apps/web/src/app/[locale]/(space)/settings/members/components/member-dropdown-menu.tsx+++ b/apps/web/src/app/[locale]/(space)/settings/members/components/member-dropdown-menu.tsx@@ -67,7 +67,11 @@ export function MemberDropdownMenu({ member }: { member: MemberDTO }) {<><DropdownMenu><DropdownMenuTrigger asChild>- <Button variant="ghost" size="icon">+ <Button+ aria-label={t("moreOptions", { defaultValue: "More options" })}+ variant="ghost"+ size="icon"+ ><Icon><MoreVerticalIcon /></Icon>diff --git a/apps/web/src/app/[locale]/(space)/settings/spaces/components/spaces-list.tsx b/apps/web/src/app/[locale]/(space)/settings/spaces/components/spaces-list.tsxindex eaff81eca..ee1705924 100644--- a/apps/web/src/app/[locale]/(space)/settings/spaces/components/spaces-list.tsx+++ b/apps/web/src/app/[locale]/(space)/settings/spaces/components/spaces-list.tsx@@ -98,7 +98,13 @@ export function SpacesList({ spaces, currentUserId }: SpacesListProps) {</div><DropdownMenu><DropdownMenuTrigger asChild>- <Button variant="ghost" size="icon">+ <Button+ aria-label={t("moreOptions", {+ defaultValue: "More options",+ })}+ variant="ghost"+ size="icon"+ ><Icon><MoreVerticalIcon /></Icon>diff --git a/apps/web/src/app/[locale]/control-panel/users/user-row.tsx b/apps/web/src/app/[locale]/control-panel/users/user-row.tsxindex 30da9325d..10b506ac4 100644--- a/apps/web/src/app/[locale]/control-panel/users/user-row.tsx+++ b/apps/web/src/app/[locale]/control-panel/users/user-row.tsx@@ -21,7 +21,7 @@ import { OptimizedAvatarImage } from "@/components/optimized-avatar-image";import { StackedListItem } from "@/components/stacked-list";import { changeRoleAction } from "@/features/user/actions";import { userRoleSchema } from "@/features/user/schema";-import { Trans } from "@/i18n/client";+import { Trans, useTranslation } from "@/i18n/client";import { useSafeAction } from "@/lib/safe-action/client";import { DeleteUserDialog } from "./dialogs/delete-user-dialog";@@ -42,6 +42,7 @@ export function UserRow({canChangeRole: boolean;canDelete: boolean;}) {+ const { t } = useTranslation();const changeRole = useSafeAction(changeRoleAction);const [isPending, startTransition] = useTransition();@@ -65,7 +66,11 @@ export function UserRow({<span className="capitalize">{role}</span><DropdownMenu><DropdownMenuTrigger asChild>- <Button variant="ghost" size="icon">+ <Button+ aria-label={t("moreOptions", { defaultValue: "More options" })}+ variant="ghost"+ size="icon"+ ><Icon><MoreHorizontal /></Icon>diff --git a/apps/web/src/app/[locale]/e/[id]/components/user-dropdown.tsx b/apps/web/src/app/[locale]/e/[id]/components/user-dropdown.tsxindex ac7d610c2..2c183a8dc 100644--- a/apps/web/src/app/[locale]/e/[id]/components/user-dropdown.tsx+++ b/apps/web/src/app/[locale]/e/[id]/components/user-dropdown.tsx@@ -14,7 +14,7 @@ import { LogOutIcon, Settings2Icon, UserIcon } from "lucide-react";import Link from "next/link";import { useRouter } from "next/navigation";import { OptimizedAvatarImage } from "@/components/optimized-avatar-image";-import { Trans } from "@/i18n/client";+import { Trans, useTranslation } from "@/i18n/client";import { signOut } from "@/lib/auth-client";export function UserDropdown({@@ -29,11 +29,17 @@ export function UserDropdown({className?: string;}) {const router = useRouter();+ const { t } = useTranslation();return (<DropdownMenu modal={false}><DropdownMenuTrigger asChild className={cn("group min-w-0", className)}>- <Button variant="ghost" className="rounded-full" size="icon">+ <Button+ aria-label={t("accountMenu", { defaultValue: "Account menu" })}+ variant="ghost"+ className="rounded-full"+ size="icon"+ ><OptimizedAvatarImage src={image} name={name} size="sm" /></Button></DropdownMenuTrigger>diff --git a/apps/web/src/components/copy-link-button.tsx b/apps/web/src/components/copy-link-button.tsxindex d51848dec..2208048ad 100644--- a/apps/web/src/components/copy-link-button.tsx+++ b/apps/web/src/components/copy-link-button.tsx@@ -23,6 +23,7 @@ export function CopyLinkButton({<Tooltip open={didCopy ? true : undefined}><TooltipTrigger asChild><Button+ aria-label={t("copyLink", { defaultValue: "Copy link" })}className={className}variant="ghost"size="icon"diff --git a/apps/web/src/components/discussion/discussion.tsx b/apps/web/src/components/discussion/discussion.tsxindex 133a80570..63ea1c0e0 100644--- a/apps/web/src/components/discussion/discussion.tsx+++ b/apps/web/src/components/discussion/discussion.tsx@@ -206,7 +206,13 @@ function DiscussionInner() {{canDelete && (<DropdownMenu><DropdownMenuTrigger asChild>- <Button variant="ghost" size="icon-xs">+ <Button+ aria-label={t("moreOptions", {+ defaultValue: "More options",+ })}+ variant="ghost"+ size="icon-xs"+ ><MoreHorizontalIcon /></Button></DropdownMenuTrigger>diff --git a/apps/web/src/components/forms/poll-options-form/month-calendar/month-calendar.tsx b/apps/web/src/components/forms/poll-options-form/month-calendar/month-calendar.tsxindex befaaa113..aae19dbe2 100644--- a/apps/web/src/components/forms/poll-options-form/month-calendar/month-calendar.tsx+++ b/apps/web/src/components/forms/poll-options-form/month-calendar/month-calendar.tsx@@ -419,6 +419,9 @@ const MonthCalendar: React.FunctionComponent<DateTimePickerProps> = ({}}/><Button+ aria-label={t("removeTimeSlot", {+ defaultValue: "Remove time slot",+ })}size="icon"variant="ghost"onClick={() => {@@ -469,7 +472,13 @@ const MonthCalendar: React.FunctionComponent<DateTimePickerProps> = ({</Button><DropdownMenu><DropdownMenuTrigger asChild={true}>- <Button variant="ghost" size="icon">+ <Button+ aria-label={t("moreOptions", {+ defaultValue: "More options",+ })}+ variant="ghost"+ size="icon"+ ><MoreVerticalIcon /></Button></DropdownMenuTrigger>diff --git a/apps/web/src/components/poll/desktop-poll.tsx b/apps/web/src/components/poll/desktop-poll.tsxindex ca15ee7a9..1c23f67bb 100644--- a/apps/web/src/components/poll/desktop-poll.tsx+++ b/apps/web/src/components/poll/desktop-poll.tsx@@ -81,6 +81,7 @@ function TableControls({onGoToPreviousPage: () => void;onGoToNextPage: () => void;}) {+ const { t } = useTranslation();return (<div className="flex items-center gap-4">{showTimeZone ? (@@ -98,6 +99,7 @@ function TableControls({<Tooltip><TooltipTrigger asChild><Button+ aria-label={t("scrollLeft", { defaultValue: "Scroll Left" })}variant="ghost"size="icon"disabled={!canScrollPrev}@@ -115,6 +117,9 @@ function TableControls({<Tooltip><TooltipTrigger asChild><Button+ aria-label={t("scrollRight", {+ defaultValue: "Scroll Right",+ })}className="relative"variant="ghost"size="icon"@@ -139,7 +144,12 @@ function TableControls({{expanded ? (<Tooltip><TooltipTrigger asChild>- <Button variant="ghost" size="icon" onClick={onCollapse}>+ <Button+ aria-label={t("shrink", { defaultValue: "Shrink" })}+ variant="ghost"+ size="icon"+ onClick={onCollapse}+ ><Icon><ShrinkIcon /></Icon>@@ -152,7 +162,12 @@ function TableControls({) : (<Tooltip delayDuration={0}><TooltipTrigger asChild>- <Button variant="ghost" size="icon" onClick={onExpand}>+ <Button+ aria-label={t("expand", { defaultValue: "Expand" })}+ variant="ghost"+ size="icon"+ onClick={onExpand}+ ><Icon><ExpandIcon /></Icon>@@ -258,6 +273,9 @@ const DesktopPoll: React.FunctionComponent = () => {<Badge>{participants.length}</Badge>{canAddNewParticipant && mode !== "new" ? (<Button+ aria-label={t("addParticipant", {+ defaultValue: "Add participant",+ })}className="ml-2"size="icon-xs"data-testid="add-participant-button"diff --git a/apps/web/src/components/poll/desktop-poll/participant-row-form.tsx b/apps/web/src/components/poll/desktop-poll/participant-row-form.tsxindex 4ffd72d2d..b9e83c7f5 100644--- a/apps/web/src/components/poll/desktop-poll/participant-row-form.tsx+++ b/apps/web/src/components/poll/desktop-poll/participant-row-form.tsx@@ -77,6 +77,7 @@ const ParticipantRowForm = ({<Tooltip><TooltipTrigger asChild><Button+ aria-label={t("cancel", { defaultValue: "Cancel" })}variant="ghost"onClick={() => {form.cancel();diff --git a/apps/web/src/components/poll/desktop-poll/participant-row.tsx b/apps/web/src/components/poll/desktop-poll/participant-row.tsxindex 0e2a35568..272142608 100644--- a/apps/web/src/components/poll/desktop-poll/participant-row.tsx+++ b/apps/web/src/components/poll/desktop-poll/participant-row.tsx@@ -13,7 +13,7 @@ import { ParticipantDropdown } from "@/components/participant-dropdown";import { usePoll } from "@/components/poll-context";import { useUser } from "@/components/user-provider";import { usePermissions } from "@/contexts/permissions";-import { Trans } from "@/i18n/client";+import { Trans, useTranslation } from "@/i18n/client";import type { Vote } from "@/trpc/client/types";import VoteIcon from "../vote-icon";@@ -96,6 +96,7 @@ const ParticipantRow: React.FunctionComponent<ParticipantRowProps> = ({className,onChangeEditMode,}) => {+ const { t } = useTranslation();const { ownsObject } = useUser();const { getVote, optionIds } = usePoll();@@ -132,7 +133,11 @@ const ParticipantRow: React.FunctionComponent<ParticipantRowProps> = ({align="start"onEdit={() => onChangeEditMode?.(true)}>- <Button size="icon-xs" variant="ghost">+ <Button+ aria-label={t("moreOptions", { defaultValue: "More options" })}+ size="icon-xs"+ variant="ghost"+ ><MoreHorizontalIcon /></Button></ParticipantDropdown>diff --git a/apps/web/src/components/poll/mobile-poll.tsx b/apps/web/src/components/poll/mobile-poll.tsxindex 8c41e4b13..a48bd8beb 100644--- a/apps/web/src/components/poll/mobile-poll.tsx+++ b/apps/web/src/components/poll/mobile-poll.tsx@@ -144,12 +144,18 @@ const MobilePoll: React.FunctionComponent = () => {votingForm.setEditingParticipantId(selectedParticipant.id);}}>- <Button size="icon">+ <Button+ aria-label={t("moreOptions", { defaultValue: "More options" })}+ size="icon"+ ><MoreVerticalIcon /></Button></ParticipantDropdown>) : canAddNewParticipant ? (<Button+ aria-label={t("addParticipant", {+ defaultValue: "Add participant",+ })}size="icon"onClick={() => {votingForm.newParticipant();diff --git a/apps/web/src/components/user-dropdown.tsx b/apps/web/src/components/user-dropdown.tsxindex 1f22f754b..4c868f182 100644--- a/apps/web/src/components/user-dropdown.tsx+++ b/apps/web/src/components/user-dropdown.tsx@@ -33,11 +33,12 @@ import { useRouter } from "next/navigation";import { OptimizedAvatarImage } from "@/components/optimized-avatar-image";import { useUser } from "@/components/user-provider";import { useTheme } from "@/features/theme/client";-import { Trans } from "@/i18n/client";+import { Trans, useTranslation } from "@/i18n/client";import { signOut } from "@/lib/auth-client";import { useFeatureFlag } from "@/lib/feature-flags/client";export const UserDropdown = ({ className }: { className?: string }) => {+ const { t } = useTranslation();const { user } = useUser();const router = useRouter();const { theme, setTheme } = useTheme();@@ -74,7 +75,12 @@ export const UserDropdown = ({ className }: { className?: string }) => {asChildclassName={cn("group min-w-0", className)}>- <Button variant="ghost" className="rounded-full" size="icon">+ <Button+ aria-label={t("accountMenu", { defaultValue: "Account menu" })}+ variant="ghost"+ className="rounded-full"+ size="icon"+ ><OptimizedAvatarImage src={image} name={name} size="sm" /></Button></DropdownMenuTrigger>diff --git a/apps/web/src/features/poll/components/polls-infinite-list.tsx b/apps/web/src/features/poll/components/polls-infinite-list.tsxindex 01e763728..fa3a51dcb 100644--- a/apps/web/src/features/poll/components/polls-infinite-list.tsx+++ b/apps/web/src/features/poll/components/polls-infinite-list.tsx@@ -36,7 +36,7 @@ import { Spinner } from "@/components/spinner";import { StackedList, StackedListItem } from "@/components/stacked-list";import { PollStatusIcon } from "@/features/poll/components/poll-status-icon";import type { PollStatus } from "@/features/poll/schema";-import { Trans } from "@/i18n/client";+import { Trans, useTranslation } from "@/i18n/client";import { trpc } from "@/trpc/client";interface PollsInfiniteListProps {@@ -59,6 +59,7 @@ function PollListItem({participants: { id: string; name: string }[];user: { name: string; image: string | null } | null;}) {+ const { t } = useTranslation();const deletePollDialog = useDialog();const deletePoll = trpc.polls.markAsDeleted.useMutation();const closePoll = trpc.polls.close.useMutation();@@ -129,7 +130,11 @@ function PollListItem({<CopyLinkButton href={shortUrl(`/invite/${id}`)} /><DropdownMenu><DropdownMenuTrigger asChild>- <Button variant="ghost" size="icon">+ <Button+ aria-label={t("moreOptions", { defaultValue: "More options" })}+ variant="ghost"+ size="icon"+ ><MoreVerticalIcon /></Button></DropdownMenuTrigger>diff --git a/apps/web/src/features/scheduled-event/components/scheduled-event-list.tsx b/apps/web/src/features/scheduled-event/components/scheduled-event-list.tsxindex 5ca37a28e..2c3e2898c 100644--- a/apps/web/src/features/scheduled-event/components/scheduled-event-list.tsx+++ b/apps/web/src/features/scheduled-event/components/scheduled-event-list.tsx@@ -28,7 +28,7 @@ import { CopyLinkButton } from "@/components/copy-link-button";import { OptimizedAvatarImage } from "@/components/optimized-avatar-image";import { StackedList } from "@/components/stacked-list";import { isScheduledEventEnabled } from "@/features/scheduled-event/constants";-import { Trans } from "@/i18n/client";+import { Trans, useTranslation } from "@/i18n/client";import { FormattedDateTime } from "@/lib/timezone/client/formatted-date-time";import { trpc } from "@/trpc/client";@@ -55,6 +55,7 @@ export function ScheduledEventListItem({floating: boolean;createdBy: { name: string; image?: string };}) {+ const { t } = useTranslation();const dialog = useDialog();const cancelEvent = trpc.events.cancel.useMutation({onSuccess: () => {@@ -164,7 +165,11 @@ export function ScheduledEventListItem({{status !== "canceled" ? (<DropdownMenu><DropdownMenuTrigger asChild>- <Button variant="ghost" size="icon">+ <Button+ aria-label={t("moreOptions", { defaultValue: "More options" })}+ variant="ghost"+ size="icon"+ ><Icon><MoreVerticalIcon /></Icon>diff --git a/biome-plugins/use-icon-button-label.grit b/biome-plugins/use-icon-button-label.gritnew file mode 100644index 000000000..ecacdddf3--- /dev/null+++ b/biome-plugins/use-icon-button-label.grit@@ -0,0 +1,40 @@+// WCAG 1.1.1 / 4.1.2: icon-only buttons need an accessible name.+// A <Button> with an icon-* size must provide a name via aria-label,+// aria-labelledby, title, or visually-hidden (sr-only) text.+language js++or {+ `<Button $props />` where {+ $props <: or {+ contains `size="icon"`,+ contains `size="icon-xs"`,+ contains `size="icon-sm"`,+ contains `size="icon-lg"`+ },+ $props <: not contains JsxAttribute(name=$name) where {+ $name <: or {+ `aria-label`,+ `aria-labelledby`,+ `title`+ }+ }+ },+ `<Button $props>$children</Button>` where {+ $props <: or {+ contains `size="icon"`,+ contains `size="icon-xs"`,+ contains `size="icon-sm"`,+ contains `size="icon-lg"`+ },+ $props <: not contains JsxAttribute(name=$name) where {+ $name <: or {+ `aria-label`,+ `aria-labelledby`,+ `title`+ }+ },+ $children <: not contains `className="sr-only"`+ }+} where {+ register_diagnostic(span=$props, message="Icon-only Button must have an accessible name: add `aria-label`, `aria-labelledby`, `title`, or visually-hidden (sr-only) text (WCAG 1.1.1 / 4.1.2).")+}diff --git a/biome.json b/biome.jsonindex 54adeb9eb..ef5326475 100644--- a/biome.json+++ b/biome.json@@ -1,6 +1,7 @@{"$schema": "https://biomejs.dev/schemas/2.3.14/schema.json","root": true,+ "plugins": ["./biome-plugins/use-icon-button-label.grit"],"assist": { "actions": { "source": { "organizeImports": "on" } } },"linter": {"enabled": true,diff --git a/packages/ui/src/combobox.tsx b/packages/ui/src/combobox.tsxindex 90835385c..fe86793f2 100644--- a/packages/ui/src/combobox.tsx+++ b/packages/ui/src/combobox.tsx@@ -256,7 +256,7 @@ function ComboboxChip({className="-ml-1 opacity-50 hover:opacity-100"data-slot="combobox-chip-remove"render={- <Button variant="ghost" size="icon-xs">+ <Button aria-label="Remove" variant="ghost" size="icon-xs"><XIcon className="pointer-events-none" /></Button>}