fix: show tag only one selected

This commit is contained in:
jialin
2026-04-22 13:16:48 +08:00
committed by jialin
parent 94d3fa356c
commit 3a58bd1eef
5 changed files with 54 additions and 32 deletions
+13 -2
View File
@@ -54,7 +54,13 @@ const SimpleSelect: React.FC<
}
> = forwardRef((props, ref) => {
const intl = useIntl();
const { options = [], showTags, styles = {}, ...restProps } = props;
const {
options = [],
showTags: tagsVisible,
styles = {},
maxTagCount: tagCount,
...restProps
} = props;
const [allSelection, setAllSelection] = React.useState<{
checked: boolean;
@@ -67,6 +73,10 @@ const SimpleSelect: React.FC<
const selectRef = React.useRef<any>(null);
const selectorRef = React.useRef<any>(null);
const showTags = Array.isArray(props.value) && props.value.length === 1;
const maxTagCount =
Array.isArray(props.value) && props.value.length === 1 ? 1 : 0;
useEffect(() => {
setOptionsList(options || []);
}, [options]);
@@ -268,8 +278,9 @@ const SimpleSelect: React.FC<
...styles.select
}}
ref={selectorRef}
maxTagTextLength={restProps.maxTagTextLength ?? 15}
options={optionsList}
maxTagCount={restProps.maxTagCount || 0}
maxTagCount={maxTagCount}
defaultActiveFirstOption={false}
popupRender={dropdownRender}
optionRender={optionRender}