From 9d5789332a82770c1d9b4e624823e8c36764869c Mon Sep 17 00:00:00 2001 From: shisongyan Date: Thu, 28 Jan 2021 19:35:18 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E5=85=BC=E5=AE=B9=20labelInValue=20?= =?UTF-8?q?=E6=97=B6=20value=20=E4=B8=BA=20null=20=E5=BC=95=E8=B5=B7?= =?UTF-8?q?=E7=9A=84=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/commonUtil.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/commonUtil.ts b/src/utils/commonUtil.ts index e60d8294d..cf8b8ceaa 100644 --- a/src/utils/commonUtil.ts +++ b/src/utils/commonUtil.ts @@ -22,7 +22,11 @@ export function toInnerValue( ): [RawValueType[], Map] { const valueMap = new Map(); - if (value === undefined || (value === '' && combobox)) { + if ( + value === null || + value === undefined || + (value === '' && combobox) + ) { return [[], valueMap]; } From b4b43b8d72c3ef16553c122721668d39c6e4bd73 Mon Sep 17 00:00:00 2001 From: shisongyan Date: Sat, 30 Jan 2021 11:03:26 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E5=85=BC=E5=AE=B9=20labelInValue=20?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E4=B8=8B=20value=20=E4=B8=BA=20null=20?= =?UTF-8?q?=E5=BC=95=E8=B5=B7=E7=9A=84=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/commonUtil.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/utils/commonUtil.ts b/src/utils/commonUtil.ts index cf8b8ceaa..e57a3405c 100644 --- a/src/utils/commonUtil.ts +++ b/src/utils/commonUtil.ts @@ -23,7 +23,6 @@ export function toInnerValue( const valueMap = new Map(); if ( - value === null || value === undefined || (value === '' && combobox) ) { @@ -34,12 +33,14 @@ export function toInnerValue( let rawValues = values as RawValueType[]; if (labelInValue) { - rawValues = (values as LabelValueType[]).map((itemValue: LabelValueType) => { - const { key, value: val } = itemValue; - const finalVal = val !== undefined ? val : key; - valueMap.set(finalVal, itemValue); - return finalVal; - }); + rawValues = (values as LabelValueType[]) + .filter(item => !!item) + .map((itemValue: LabelValueType) => { + const { key, value: val } = itemValue; + const finalVal = val !== undefined ? val : key; + valueMap.set(finalVal, itemValue); + return finalVal; + }); } return [rawValues, valueMap]; From ee53e1c88d51d8ad5c918d7ac89996d6834820a2 Mon Sep 17 00:00:00 2001 From: shisongyan Date: Sat, 30 Jan 2021 11:53:07 +0800 Subject: [PATCH 3/3] test: not crash when labelInValue and value is null --- tests/Select.test.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/Select.test.tsx b/tests/Select.test.tsx index 961d39aaf..7a52c95af 100644 --- a/tests/Select.test.tsx +++ b/tests/Select.test.tsx @@ -1463,6 +1463,10 @@ describe('Select.Basic', () => { mount(); + }); + it('not open when `notFoundCount` is empty & no data', () => { const wrapper = mount(