fix(web): expose error disclosure state (#10125)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
00d6109cbb
commit
127efae440
1 file changed
+5
-1
@@ -1,4 +1,4 @@
|
||||
import { useState } from "react";
|
||||
import { useId, useState } from "react";
|
||||
|
||||
import { cn } from "../../lib/utils";
|
||||
|
||||
@@ -17,12 +17,14 @@ export function ExpandableText({
|
||||
collapsedClassName?: string;
|
||||
expandLabel?: string;
|
||||
}) {
|
||||
const textId = useId();
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
const canExpand = text.length > 180 || text.includes("\n");
|
||||
|
||||
return (
|
||||
<div className={cn("min-w-0", className)}>
|
||||
<div
|
||||
id={textId}
|
||||
className={cn(
|
||||
"whitespace-pre-wrap break-words",
|
||||
!expanded && canExpand ? collapsedClassName : null,
|
||||
@@ -33,6 +35,8 @@ export function ExpandableText({
|
||||
{canExpand ? (
|
||||
<button
|
||||
type="button"
|
||||
aria-expanded={expanded}
|
||||
aria-controls={textId}
|
||||
className="cursor-pointer mt-1 text-[11px] font-medium text-foreground/70 underline-offset-2 hover:text-foreground hover:underline"
|
||||
onClick={() => setExpanded((value) => !value)}
|
||||
>
|
||||
|
||||
Reference in new issue
Block a user