From 26ae14dc2df80b0e7109f7c223d616d761f35eed Mon Sep 17 00:00:00 2001 From: Julius Osokinas Date: Mon, 25 Jul 2022 10:57:06 +0100 Subject: [PATCH] fix(react): correctly init options when value (or defaultValue) provided --- .../components/option-list/options-list-init.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/react/src/components/option-list/options-list-init.tsx b/packages/react/src/components/option-list/options-list-init.tsx index 168b9f77b..c53b4975a 100644 --- a/packages/react/src/components/option-list/options-list-init.tsx +++ b/packages/react/src/components/option-list/options-list-init.tsx @@ -1,4 +1,5 @@ import React, { useRef } from 'react'; +import { ComboboxProps } from '../combobox/combobox'; import { CustomSelectProps } from '../select/custom'; import { OptionListEvent } from './option-list'; import { OptionListProvider } from './useOptionList'; @@ -8,19 +9,25 @@ export const OptionListInit = ({ defaultValue, value, onInit, -}: Pick & { +}: ( + | Pick + | Pick +) & { onInit: (selected: OptionListEvent) => void; }) => { const hasInit = useRef(false); + const currentValue = value ?? defaultValue; return (