From b7116dd547148d3aad20ef08bdec60d9ec9beba9 Mon Sep 17 00:00:00 2001 From: songjiaming Date: Tue, 18 Jun 2024 10:36:01 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3Picker=20=E5=92=8C?= =?UTF-8?q?=20FormItem=20=E6=90=AD=E9=85=8D=E4=BD=BF=E7=94=A8=E6=97=B6?= =?UTF-8?q?=EF=BC=8Cref.open()=20=E4=BC=9A=E8=A7=A6=E5=8F=91=20Picker=20?= =?UTF-8?q?=E7=9A=84=20onClose=E9=97=AE=E9=A2=98=20--issue#2312?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/picker/picker.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/picker/picker.tsx b/src/packages/picker/picker.tsx index 28516ba2be..05e19ef43d 100644 --- a/src/packages/picker/picker.tsx +++ b/src/packages/picker/picker.tsx @@ -98,7 +98,7 @@ const InternalPicker: ForwardRefRenderFunction< defaultValue: [...defaultValue], finalValue: [...defaultValue], onChange: (val: (string | number)[]) => { - props.onConfirm?.(setSelectedOptions(), val) + !val && props.onConfirm?.(setSelectedOptions(), val) }, }) const [innerVisible, setInnerVisible] = usePropsValue({ From 6aba177275f8340a062d64cc825aa5b4d872c6af Mon Sep 17 00:00:00 2001 From: songjiaming Date: Tue, 18 Jun 2024 10:37:31 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9onChange=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E6=97=B6=E6=9C=BA=EF=BC=8C=E8=A7=A3=E5=86=B3=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=E6=89=93=E5=BC=80=E5=B0=B1=E8=A7=A6=E5=8F=91?= =?UTF-8?q?onChange=E4=B8=94=E4=BC=A0=E5=80=BC=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/picker/picker.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/packages/picker/picker.tsx b/src/packages/picker/picker.tsx index 05e19ef43d..2f69c0cbaf 100644 --- a/src/packages/picker/picker.tsx +++ b/src/packages/picker/picker.tsx @@ -206,11 +206,6 @@ const InternalPicker: ForwardRefRenderFunction< } }, [options, innerVisible]) - // 选中值进行修改 - useEffect(() => { - onChange && onChange(setSelectedOptions(), innerValue, columnIndex) - }, [innerValue, columnsList]) - const setSelectedOptions = () => { const options: PickerOption[] = [] let currOptions = [] @@ -251,6 +246,8 @@ const InternalPicker: ForwardRefRenderFunction< ] setInnerValue(combineResult) setColumnsList(normalListData(combineResult) as PickerOption[][]) + + onChange && onChange(setSelectedOptions(), combineResult, columnIndex) } else { setInnerValue((data: (number | string)[]) => { const cdata: (number | string)[] = [...data] @@ -260,6 +257,7 @@ const InternalPicker: ForwardRefRenderFunction< ) ? columnOptions.value : '' + onChange && onChange(setSelectedOptions(), cdata, columnIndex) return cdata }) } From 76a5e85c9178b266e74834b1563eb9b0f5fe6068 Mon Sep 17 00:00:00 2001 From: songjiaming Date: Tue, 18 Jun 2024 10:38:25 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9form=E4=B8=8B?= =?UTF-8?q?=E7=9A=84picker=E5=9C=A8=E7=AC=AC=E4=B8=80=E6=AC=A1=E4=B8=8D?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E9=80=89=E9=A1=B9=EF=BC=8C=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E9=80=89=E6=8B=A9=E5=90=8E=E5=86=8D=E6=AC=A1?= =?UTF-8?q?=E7=82=B9=E5=87=BBpicker=EF=BC=8C=E5=87=BA=E7=8E=B0=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E9=A1=B9=E8=A2=AB=E9=80=89=E4=B8=AD=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20--issue#2290?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/picker/picker.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/packages/picker/picker.tsx b/src/packages/picker/picker.tsx index 2f69c0cbaf..d6301ab4c8 100644 --- a/src/packages/picker/picker.tsx +++ b/src/packages/picker/picker.tsx @@ -197,7 +197,11 @@ const InternalPicker: ForwardRefRenderFunction< } useEffect(() => { - setInnerValue(innerValue !== selectedValue ? selectedValue : innerValue) + // 此hook的作用是‘如果内部选中值与用户选中值不同则把内部值置用户选中值’保证用户打开选项时选中的是选择的值。 + // 但是当用户并没有进行确认选择,则不需要进行修改innerValue,否则会出现 issue#2290的问题 + if (innerValue !== selectedValue && selectedValue.length > 0) { + setInnerValue(selectedValue) + } }, [innerVisible, selectedValue]) useEffect(() => {