Skip to content

Commit

Permalink
Bugfixes: correct behavior for alttext errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate Lanza committed Jul 20, 2024
1 parent 76bbe1a commit 90a345f
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions packages/upset/src/components/AltTextSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const AltTextSidebar: FC<Props> = ({ open, close, generateAltText }) => {
const currState = useRecoilValue(upsetConfigAtom);

const [altText, setAltText] = useState<AltText | null>(null);
const [textGenErr, setTextGenErr] = useState(false);
const [textGenErr, setTextGenErr] = useState<string | false>(false);

// States for editing the alt text
const [textEditing, setTextEditing] = useState(false);
Expand All @@ -65,13 +65,7 @@ export const AltTextSidebar: FC<Props> = ({ open, close, generateAltText }) => {
setTextGenErr(false);
} catch (e) {
const msg: string = (e as Error).message;
// We want the error message to display on the frontend
setAltText({
longDescription: msg,
shortDescription: msg,
techniqueDescription: msg,
});
setTextGenErr(true);
setTextGenErr(msg);
}
}

Expand Down Expand Up @@ -178,7 +172,9 @@ export const AltTextSidebar: FC<Props> = ({ open, close, generateAltText }) => {
text={"When enabled, displays the long text description for this plot instead of the short version."}
margin={{left: 12, top: 0, right: 0, bottom: 0}}
/>
</>) : null}
</>) : (
<Typography variant="body1" color="error">{textGenErr}</Typography>
)}
{textEditing ? (<>
<Button
color="primary"
Expand Down Expand Up @@ -230,9 +226,9 @@ export const AltTextSidebar: FC<Props> = ({ open, close, generateAltText }) => {
>
<ReactMarkdownWrapper
text={
displayAltText ?? currState.useUserAlt
displayAltText ?? (currState.useUserAlt
? "No user-generated description available."
: "No description available."
: "No description available.")
}
/>
<Button
Expand Down

0 comments on commit 90a345f

Please sign in to comment.