Skip to content

Commit

Permalink
fix: repeated label removed from file on change click bug (#2443)
Browse files Browse the repository at this point in the history
- When the modal was rendered it was incorrectly updating the fileList as the previousTags variable was undefined.
- The update function for each SelectMultiple would set the file it controlled as the only file with that label
- Set the previousTags to the last state or the initialTags on first render
- Updates are checked but an update isn't applied as the previousTags = intialTags
  • Loading branch information
Mike-Heneghan authored Nov 20, 2023
1 parent 33742d2 commit 56a493f
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const SelectMultiple = (props: SelectMultipleProps) => {

const initialTags = getTagsForSlot(uploadedFile.id, fileList);
const [tags, setTags] = useState<string[]>(initialTags);
const previousTags = usePrevious(tags);
const previousTags = usePrevious(tags) || initialTags;
const [open, setOpen] = React.useState(false);

const handleChange = (event: SelectChangeEvent<typeof tags>) => {
Expand Down

0 comments on commit 56a493f

Please sign in to comment.