Skip to content

Commit

Permalink
Refactor prevSelectedIds in DropDownField
Browse files Browse the repository at this point in the history
  • Loading branch information
fogarea committed Nov 8, 2024
1 parent 2dd3d21 commit 345e3d8
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/ui/form/DropDownField/DropDownField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,6 @@ function DropDownField(props: IDropDownFieldProps & IFieldWrapperOutputProps): J
inputValue: props.input.value,
});

const prevSelectedIds = usePrevious(selectedIds);

const onOpen = useCallback(() => {
setQuery('');
setIsFocused(true);
Expand Down Expand Up @@ -384,6 +382,7 @@ function DropDownField(props: IDropDownFieldProps & IFieldWrapperOutputProps): J
}), [props]);

// Sync with form
const prevSelectedIds = usePrevious(selectedIds);
useEffect(() => {
if (!_isEqual(prevSelectedIds || [], selectedIds)) {
const newValues = props.multiple ? selectedIds : (selectedIds[0] || null);
Expand Down

0 comments on commit 345e3d8

Please sign in to comment.