From a9e808ae056cd269ec013823526b13bd3ca51dc3 Mon Sep 17 00:00:00 2001 From: liangfeng_wang Date: Tue, 26 Nov 2024 10:30:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20[select]=20=E4=BF=AE=E5=A4=8DonDeselect?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E4=BA=8B=E4=BB=B6=E8=A7=A6=E5=8F=91=E6=97=B6?= =?UTF-8?q?=E6=9C=BA=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98=20fix=20#949?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/select/option.tsx | 6 ++++-- components/select/select.tsx | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/components/select/option.tsx b/components/select/option.tsx index ed84f8d2..5f156a0d 100755 --- a/components/select/option.tsx +++ b/components/select/option.tsx @@ -57,11 +57,13 @@ const InternalOption: React.ForwardRefRenderFunction) => { e.preventDefault() + let newVal = isSelected if (optionProps.disabled || value === undefined) return if (isMultiple) { - setSelected(!isSelected) + newVal = !isSelected + setSelected(newVal) } - onChangeSelect && onChangeSelect(value, children, isSelected) + onChangeSelect && onChangeSelect(value, children, newVal) } const handleOnMouseEnter = () => { onChangeActiveIndex && onChangeActiveIndex(index) diff --git a/components/select/select.tsx b/components/select/select.tsx index ffab087a..f4824ace 100755 --- a/components/select/select.tsx +++ b/components/select/select.tsx @@ -863,7 +863,11 @@ const InternalSelect: React.ForwardRefRenderFunction> if (!item) return const key = item.props?.value || item.value const label = item.props?.children || item.label - handleOption(key, label, true) + let flag = true + if (isMultiple) { + flag = !mulOptions?.some((item: any) => item.value === key) + } + handleOption(key, label, flag) // search if (searchValue) { setActiveIndex(