History

fix(web): expose error disclosure state (#10125)

Alex Southwell committed 2 months ago

Commit 127efae1 parent 00d61091 file · +5 −1Browse files

Unified · Split

apps/web/src/components/settings/ExpandableText.tsx+5−1
@@ -1,4 +1,4 @@
1−import { useState } from "react";
1+import { useId, useState } from "react";
22
33 import { cn } from "../../lib/utils";
44
@@ -17,12 +17,14 @@ export function ExpandableText({ · 12 unmodified lines
1717 collapsedClassName?: string;
1818 expandLabel?: string;
1919 }) {
20+ const textId = useId();
2021 const [expanded, setExpanded] = useState(false);
2122 const canExpand = text.length > 180 || text.includes("\n");
2223
2324 return (
2425 <div className={cn("min-w-0", className)}>
2526 <div
27+ id={textId}
2628 className={cn(
2729 "whitespace-pre-wrap break-words",
2830 !expanded && canExpand ? collapsedClassName : null,
@@ -33,6 +35,8 @@ export function ExpandableText({ · 4 unmodified lines
3335 {canExpand ? (
3436 <button
3537 type="button"
38+ aria-expanded={expanded}
39+ aria-controls={textId}
3640 className="cursor-pointer mt-1 text-[11px] font-medium text-foreground/70 underline-offset-2 hover:text-foreground hover:underline"
3741 onClick={() => setExpanded((value) => !value)}
3842 >