From 362ad34139156544dc97abaeab16692243950798 Mon Sep 17 00:00:00 2001 From: Brandon Dow Date: Tue, 30 Apr 2024 16:36:08 -0400 Subject: [PATCH] fix: Prevent mutating value prop --- src/inputs/internal/ComboBoxBase.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inputs/internal/ComboBoxBase.tsx b/src/inputs/internal/ComboBoxBase.tsx index 119704c9b..e467a83ad 100644 --- a/src/inputs/internal/ComboBoxBase.tsx +++ b/src/inputs/internal/ComboBoxBase.tsx @@ -138,7 +138,7 @@ export function ComboBoxBase(props: ComboBoxBaseProps) // Though, it is possible that the `options` prop has changed, which is a dependency on this `useMemo`. // That could trigger an unnecessary new reference for `selectedOptions`, and cause additional renders or unexpected state changes. // We should avoid updating `selectedOptions` unless `values` has actually changed. - if (!equal(values.sort(), selectedOptionsRef.current.map(getOptionValue).sort())) { + if (!equal([...values].sort(), selectedOptionsRef.current.map(getOptionValue).sort())) { selectedOptionsRef.current = options.filter((o) => values.includes(getOptionValue(o))); }