Skip to content

Commit

Permalink
Fix dialog warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
evadecker committed Dec 17, 2024
1 parent 4d619ad commit 5254f77
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 31 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"check": "tsc -b && biome check",
"check:fix": "tsc -b && biome check --write",
"preview": "vite preview",
"scan": "npx react-scan@latest localhost:5173",
"test": "vitest",
"test:once": "vitest run",
"test:debug": "vitest --inspect-brk --no-file-parallelism",
Expand Down
2 changes: 1 addition & 1 deletion src/components/app/AppSidebar/AppSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const AppSidebar = ({ children }: AppSidebarProps) => {
{THEMES[theme as Theme].label}
</span>
</MenuItem>
<Popover>
<Popover title="Select a theme">
<Menu
disallowEmptySelection
selectionMode="single"
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function ComboBox<T extends object>({
</FieldGroup>
{description && <FieldDescription>{description}</FieldDescription>}
<FieldError>{errorMessage}</FieldError>
<Popover className="w-[--trigger-width]">
<Popover title="Select an option" className="w-[--trigger-width]">
<ListBox
items={items}
className="outline-0 p-1 max-h-[inherit] overflow-auto [clip-path:inset(0_0_0_0_round_.75rem)]"
Expand Down
7 changes: 2 additions & 5 deletions src/components/common/DatePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
import { Button } from "../Button";
import { Calendar } from "../Calendar";
import { DateInput } from "../DateField";
import { Dialog } from "../Dialog";
import { FieldDescription, FieldError, FieldGroup, Label } from "../Field";
import { Popover } from "../Popover";

Expand Down Expand Up @@ -43,10 +42,8 @@ export function DatePicker<T extends DateValue>({
</FieldGroup>
{description && <FieldDescription>{description}</FieldDescription>}
<FieldError>{errorMessage}</FieldError>
<Popover>
<Dialog>
<Calendar />
</Dialog>
<Popover title="Select a date">
<Calendar />
</Popover>
</AriaDatePicker>
);
Expand Down
7 changes: 2 additions & 5 deletions src/components/common/DateRangePicker/DateRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from "react-aria-components";
import { Button } from "../Button";
import { DateInput } from "../DateField";
import { Dialog } from "../Dialog";
import { FieldDescription, FieldError, FieldGroup, Label } from "../Field";
import { Popover } from "../Popover";
import { RangeCalendar } from "../RangeCalendar";
Expand Down Expand Up @@ -50,10 +49,8 @@ export function DateRangePicker<T extends DateValue>({
</FieldGroup>
{description && <FieldDescription>{description}</FieldDescription>}
<FieldError>{errorMessage}</FieldError>
<Popover>
<Dialog>
<RangeCalendar />
</Dialog>
<Popover title="Select a date range">
<RangeCalendar />
</Popover>
</AriaDateRangePicker>
);
Expand Down
6 changes: 3 additions & 3 deletions src/components/common/Menu/Menu.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const Submenu = (args: any) => (
<MenuItem id="new">New…</MenuItem>
<SubmenuTrigger>
<MenuItem id="open">Open</MenuItem>
<Popover>
<Popover title="Open in">
<Menu>
<MenuItem id="open-new">Open in New Window</MenuItem>
<MenuItem id="open-current">Open in Current Window</MenuItem>
Expand All @@ -81,13 +81,13 @@ export const Submenu = (args: any) => (
<MenuItem id="print">Print…</MenuItem>
<SubmenuTrigger>
<MenuItem id="share">Share</MenuItem>
<Popover>
<Popover title="Share">
<Menu>
<MenuItem id="sms">SMS</MenuItem>
<MenuItem id="twitter">Twitter</MenuItem>
<SubmenuTrigger>
<MenuItem id="email">Email</MenuItem>
<Popover>
<Popover title="Email">
<Menu>
<MenuItem id="work">Work</MenuItem>
<MenuItem id="personal">Personal</MenuItem>
Expand Down
6 changes: 5 additions & 1 deletion src/components/common/Menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export function MenuTrigger(props: MenuTriggerProps) {

export function Menu<T extends object>(props: MenuProps<T>) {
return (
<Popover placement={props.placement} className="min-w-[150px]">
<Popover
title="Select an option"
placement={props.placement}
className="min-w-[150px]"
>
<AriaMenu
{...props}
className="p-1 outline outline-0 max-h-[inherit] overflow-auto [clip-path:inset(0_0_0_0_round_.75rem)]"
Expand Down
18 changes: 7 additions & 11 deletions src/components/common/Popover/Popover.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import type { Meta } from "@storybook/react";
import { CircleHelp } from "lucide-react";
import { Heading } from "react-aria-components";
import { Popover } from ".";
import { Button } from "../Button";
import { Dialog, DialogTrigger } from "../Dialog";
import { DialogTrigger } from "../Dialog";

const meta: Meta<typeof Popover> = {
component: Popover,
args: {},
args: {
title: "Help",
},
};

export default meta;
Expand All @@ -18,14 +19,9 @@ export const Example = (args: any) => (
<CircleHelp />
</Button>
<Popover {...args} className="max-w-[250px]">
<Dialog>
<Heading slot="title" className="text-lg font-semibold mb-2">
Help
</Heading>
<p className="text-sm">
For help accessing your account, please contact support.
</p>
</Dialog>
<p className="text-sm">
For help accessing your account, please contact support.
</p>
</Popover>
</DialogTrigger>
);
11 changes: 9 additions & 2 deletions src/components/common/Popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { Dialog } from "../Dialog";

export interface PopoverProps extends Omit<AriaPopoverProps, "children"> {
children: React.ReactNode;
/** Provide a screen reader title for the popover. */
title: string;
}

const styles = tv({
Expand All @@ -25,7 +27,12 @@ const styles = tv({
},
});

export function Popover({ children, className, ...props }: PopoverProps) {
export function Popover({
children,
className,
title,
...props
}: PopoverProps) {
const popoverContext = useSlottedContext(PopoverContext)!;
const isSubmenu = popoverContext?.trigger === "SubmenuTrigger";
const offset = isSubmenu ? 2 : 8;
Expand All @@ -38,7 +45,7 @@ export function Popover({ children, className, ...props }: PopoverProps) {
styles({ ...renderProps, className }),
)}
>
<Dialog>{children}</Dialog>
<Dialog aria-label={title}>{children}</Dialog>
</AriaPopover>
);
}
2 changes: 1 addition & 1 deletion src/components/common/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function Select<T extends object>({
</Button>
{description && <FieldDescription>{description}</FieldDescription>}
<FieldError>{errorMessage}</FieldError>
<Popover className="min-w-[--trigger-width]">
<Popover title="Select an option" className="min-w-[--trigger-width]">
<ListBox
items={items}
className="outline-none p-1 max-h-[inherit] overflow-auto [clip-path:inset(0_0_0_0_round_.75rem)]"
Expand Down
4 changes: 3 additions & 1 deletion src/components/quests/StatGroup/StatGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export const StatPopover = ({ tooltip, children }: StatPopoverProps) => (
</Button>
<Tooltip>{tooltip}</Tooltip>
</TooltipTrigger>
<Popover className="p-4">{children}</Popover>
<Popover title={tooltip} className="p-4">
{children}
</Popover>
</DialogTrigger>
);

Expand Down

0 comments on commit 5254f77

Please sign in to comment.