Skip to content

Commit

Permalink
Merge pull request #316 from visdesignlab/alt-text-generation-hook
Browse files Browse the repository at this point in the history
Update alt-text generation hook to depend on the currentState
  • Loading branch information
JakeWags authored Mar 26, 2024
2 parents 40a1573 + 3641bd9 commit cb5e006
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/upset/src/components/AltTextSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ import {
} from 'react';
import { useRecoilValue } from 'recoil';
import { Edit } from '@mui/icons-material';
import { sortBySelector } from '../atoms/config/sortByAtom';
import { maxVisibleSelector, minVisibleSelector } from '../atoms/config/filterAtoms';
import { ProvenanceContext } from './Root';
import { plotInformationSelector } from '../atoms/config/plotInformationAtom';
import ReactMarkdownWrapper from './custom/ReactMarkdownWrapper';
import { upsetConfigAtom } from '../atoms/config/upsetConfigAtoms';

type Props = {
open: boolean;
Expand Down Expand Up @@ -51,9 +50,7 @@ export const AltTextSidebar: FC<Props> = ({ open, close, generateAltText }) => {
const { actions } = useContext(ProvenanceContext);
const plotInformationState = useRecoilValue(plotInformationSelector);

const sort = useRecoilValue(sortBySelector);
const minVisible = useRecoilValue(minVisibleSelector);
const maxVisible = useRecoilValue(maxVisibleSelector);
const currState = useRecoilValue(upsetConfigAtom);

const [textDescription, setTextDescription] = useState('');
const [isEditable, setIsEditable] = useState(false);
Expand All @@ -75,8 +72,10 @@ export const AltTextSidebar: FC<Props> = ({ open, close, generateAltText }) => {
setTextDescription(resp);
}

generate();
}, [sort, minVisible, maxVisible]);
if (currState.firstAggregateBy === 'None') {
generate();
}
}, [currState]);

// this useEffect resets the plot information when the edit is toggled off
useEffect(() => {
Expand Down

0 comments on commit cb5e006

Please sign in to comment.