diff --git a/packages/console/src/components/Select/index.tsx b/packages/console/src/components/Select/index.tsx index baa33ce85..775986a05 100644 --- a/packages/console/src/components/Select/index.tsx +++ b/packages/console/src/components/Select/index.tsx @@ -8,22 +8,22 @@ import Dropdown, { DropdownItem } from '../Dropdown'; import IconButton from '../IconButton'; import * as styles from './index.module.scss'; -type Option = { - value: string; +type Option = { + value: T; title: ReactNode; }; -type Props = { - value?: string; - options: Option[]; - onChange?: (value?: string) => void; +type Props = { + value?: T; + options: Array>; + onChange?: (value?: T) => void; isReadOnly?: boolean; hasError?: boolean; placeholder?: ReactNode; isClearable?: boolean; }; -const Select = ({ +const Select = ({ value, options, onChange, @@ -31,12 +31,12 @@ const Select = ({ hasError, placeholder, isClearable, -}: Props) => { +}: Props) => { const [isOpen, setIsOpen] = useState(false); const anchorRef = useRef(null); const current = options.find((option) => value && option.value === value); - const handleSelect = (value: string) => { + const handleSelect = (value: T) => { onChange?.(value); setIsOpen(false); }; diff --git a/packages/console/src/pages/SignInExperience/components/Preview.tsx b/packages/console/src/pages/SignInExperience/components/Preview.tsx index 7b3577063..ab0671222 100644 --- a/packages/console/src/pages/SignInExperience/components/Preview.tsx +++ b/packages/console/src/pages/SignInExperience/components/Preview.tsx @@ -88,7 +88,9 @@ const Preview = ({ signInExperience, className }: Props) => { { value: Language.Chinese, title: t('sign_in_exp.preview.languages.chinese') }, ]} onChange={(value) => { - setLanguage(value as Language); + if (value) { + setLanguage(value); + } }} />