prevent console errors for sheet component

This commit is contained in:
Josh Hawkins 2024-09-09 09:25:29 -05:00
parent 7dc2466ba3
commit 334c1c4d95
4 changed files with 64 additions and 7 deletions

View File

@ -1,7 +1,19 @@
import { LogLine } from "@/types/log"; import { LogLine } from "@/types/log";
import { isDesktop } from "react-device-detect"; import { isDesktop } from "react-device-detect";
import { Sheet, SheetContent } from "../ui/sheet"; import {
import { Drawer, DrawerContent } from "../ui/drawer"; Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
} from "../ui/sheet";
import {
Drawer,
DrawerContent,
DrawerDescription,
DrawerHeader,
DrawerTitle,
} from "../ui/drawer";
import { LogChip } from "../indicators/Chip"; import { LogChip } from "../indicators/Chip";
import { useMemo } from "react"; import { useMemo } from "react";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
@ -16,6 +28,9 @@ export default function LogInfoDialog({
}: LogInfoDialogProps) { }: LogInfoDialogProps) {
const Overlay = isDesktop ? Sheet : Drawer; const Overlay = isDesktop ? Sheet : Drawer;
const Content = isDesktop ? SheetContent : DrawerContent; const Content = isDesktop ? SheetContent : DrawerContent;
const Header = isDesktop ? SheetHeader : DrawerHeader;
const Title = isDesktop ? SheetTitle : DrawerTitle;
const Description = isDesktop ? SheetDescription : DrawerDescription;
const helpfulLinks = useHelpfulLinks(logLine?.content); const helpfulLinks = useHelpfulLinks(logLine?.content);
@ -31,6 +46,10 @@ export default function LogInfoDialog({
<Content <Content
className={isDesktop ? "" : "max-h-[75dvh] overflow-hidden p-2 pb-4"} className={isDesktop ? "" : "max-h-[75dvh] overflow-hidden p-2 pb-4"}
> >
<Header className="sr-only">
<Title>Log Details</Title>
<Description>Log details</Description>
</Header>
{logLine && ( {logLine && (
<div className="flex size-full flex-col gap-5"> <div className="flex size-full flex-col gap-5">
<div className="flex w-min flex-col gap-1.5"> <div className="flex w-min flex-col gap-1.5">

View File

@ -1,6 +1,18 @@
import { isDesktop, isIOS, isMobile } from "react-device-detect"; import { isDesktop, isIOS, isMobile } from "react-device-detect";
import { Sheet, SheetContent } from "../../ui/sheet"; import {
import { Drawer, DrawerContent } from "../../ui/drawer"; Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
} from "../../ui/sheet";
import {
Drawer,
DrawerContent,
DrawerDescription,
DrawerHeader,
DrawerTitle,
} from "../../ui/drawer";
import useSWR from "swr"; import useSWR from "swr";
import { FrigateConfig } from "@/types/frigateConfig"; import { FrigateConfig } from "@/types/frigateConfig";
import { useFormattedTimestamp } from "@/hooks/use-date-utils"; import { useFormattedTimestamp } from "@/hooks/use-date-utils";
@ -66,6 +78,9 @@ export default function ReviewDetailDialog({
const Overlay = isDesktop ? Sheet : Drawer; const Overlay = isDesktop ? Sheet : Drawer;
const Content = isDesktop ? SheetContent : DrawerContent; const Content = isDesktop ? SheetContent : DrawerContent;
const Header = isDesktop ? SheetHeader : DrawerHeader;
const Title = isDesktop ? SheetTitle : DrawerTitle;
const Description = isDesktop ? SheetDescription : DrawerDescription;
if (!review) { if (!review) {
return; return;
@ -102,6 +117,10 @@ export default function ReviewDetailDialog({
: "max-h-[80dvh] overflow-hidden p-2 pb-4", : "max-h-[80dvh] overflow-hidden p-2 pb-4",
)} )}
> >
<Header className="sr-only">
<Title>Review Item Details</Title>
<Description>Review item details</Description>
</Header>
{pane == "overview" && ( {pane == "overview" && (
<div className="scrollbar-container mt-3 flex size-full flex-col gap-5 overflow-y-auto"> <div className="scrollbar-container mt-3 flex size-full flex-col gap-5 overflow-y-auto">
<div className="flex w-full flex-row"> <div className="flex w-full flex-row">

View File

@ -1,6 +1,18 @@
import { isDesktop, isIOS } from "react-device-detect"; import { isDesktop, isIOS } from "react-device-detect";
import { Sheet, SheetContent } from "../../ui/sheet"; import {
import { Drawer, DrawerContent } from "../../ui/drawer"; Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
} from "../../ui/sheet";
import {
Drawer,
DrawerContent,
DrawerDescription,
DrawerHeader,
DrawerTitle,
} from "../../ui/drawer";
import { SearchResult } from "@/types/search"; import { SearchResult } from "@/types/search";
import useSWR from "swr"; import useSWR from "swr";
import { FrigateConfig } from "@/types/frigateConfig"; import { FrigateConfig } from "@/types/frigateConfig";
@ -71,6 +83,9 @@ export default function SearchDetailDialog({
const Overlay = isDesktop ? Sheet : Drawer; const Overlay = isDesktop ? Sheet : Drawer;
const Content = isDesktop ? SheetContent : DrawerContent; const Content = isDesktop ? SheetContent : DrawerContent;
const Header = isDesktop ? SheetHeader : DrawerHeader;
const Title = isDesktop ? SheetTitle : DrawerTitle;
const Description = isDesktop ? SheetDescription : DrawerDescription;
return ( return (
<Overlay <Overlay
@ -86,6 +101,10 @@ export default function SearchDetailDialog({
isDesktop ? "sm:max-w-xl" : "max-h-[75dvh] overflow-hidden p-2 pb-4" isDesktop ? "sm:max-w-xl" : "max-h-[75dvh] overflow-hidden p-2 pb-4"
} }
> >
<Header className="sr-only">
<Title>Tracked Object Details</Title>
<Description>Tracked object details</Description>
</Header>
{search && ( {search && (
<div className="mt-3 flex size-full flex-col gap-5 md:mt-0"> <div className="mt-3 flex size-full flex-col gap-5 md:mt-0">
<div className="flex w-full flex-row"> <div className="flex w-full flex-row">

View File

@ -49,7 +49,7 @@ export default function SearchView({
onUpdateFilter, onUpdateFilter,
onOpenSearch, onOpenSearch,
}: SearchViewProps) { }: SearchViewProps) {
// remove duplicate review items // remove duplicate event ids
const uniqueResults = useMemo(() => { const uniqueResults = useMemo(() => {
return searchResults?.filter( return searchResults?.filter(