Skip to content

Commit

Permalink
fix: Select component dynamic options updating doesn't work
Browse files Browse the repository at this point in the history
This fixes a few of issues such as creativetimofficial#675, creativetimofficial#513.
  • Loading branch information
dongsheng2014 committed Sep 8, 2024
1 parent 5fca58a commit 34ba74f
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,14 @@ const Select = React.forwardRef<HTMLDivElement, SelectProps>(
});

React.useEffect(() => {
listContentRef.current = [
...(React.Children.map(children, (child) => {
const { props }: any = child;
return props?.value;
}) ?? []),
]
setSelectedIndex(Math.max(0, listContentRef.current.indexOf(value) + 1));
}, [value]);
}, [value, children]);

const floatingRef = refs.floating;

Expand Down

0 comments on commit 34ba74f

Please sign in to comment.