From 0dd12df679795a20f87c2a3c0811ca9f5b7c04ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=8B?= <​> Date: Fri, 1 Oct 2049 12:00:00 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E2=80=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 1.txt diff --git a/1.txt b/1.txt new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/1.txt @@ -0,0 +1 @@ + From 2b8f4c74f41acfdaa16446a21918daecb587cd7b Mon Sep 17 00:00:00 2001 From: wuxh Date: Tue, 27 Aug 2024 23:08:27 +0800 Subject: [PATCH 2/4] chore: add unit test --- tests/Select.multiple.spec.js | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/Select.multiple.spec.js b/tests/Select.multiple.spec.js index 20a75c45..eba8a620 100644 --- a/tests/Select.multiple.spec.js +++ b/tests/Select.multiple.spec.js @@ -310,4 +310,42 @@ describe('TreeSelect.multiple', () => { ).map(ele => ele.textContent); expect(values).toEqual(['child1', 'child2', 'parent']); }); + + // https://github.com/ant-design/ant-design/issues/50578#issuecomment-2312130715 + it('should not omit value when value is null', () => { + const { container } = render( + , + ); + + const values = Array.from( + container.querySelectorAll('.rc-tree-select-selection-item-content'), + ); //.map(ele => ele.textContent); + + expect(values).toHaveLength(0); + + const placeholder = container.querySelector('[class$=placeholder]'); + expect(placeholder).toBeTruthy(); + expect(placeholder.textContent).toBe('Fake placeholder'); + }); + }); From 302e06e2ae20b4f205c6af58630623bc6957fbfd Mon Sep 17 00:00:00 2001 From: wuxh Date: Tue, 27 Aug 2024 23:10:37 +0800 Subject: [PATCH 3/4] fix: improve to not treat as a valid option when the value is null. --- src/TreeSelect.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TreeSelect.tsx b/src/TreeSelect.tsx index 88778dc9..0843e358 100644 --- a/src/TreeSelect.tsx +++ b/src/TreeSelect.tsx @@ -390,7 +390,7 @@ const TreeSelect = React.forwardRef((props, ref) // =========================== Values =========================== const rawMixedLabeledValues = React.useMemo( - () => toLabeledValues(internalValue), + () => toLabeledValues(internalValue === null ? [] : internalValue), [toLabeledValues, internalValue], ); From e5223d56ab7f81a9e19c3d3822751478160d4d70 Mon Sep 17 00:00:00 2001 From: wuxh Date: Tue, 27 Aug 2024 23:18:12 +0800 Subject: [PATCH 4/4] =?UTF-8?q?Revert=20"=E2=80=8B"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 0dd12df679795a20f87c2a3c0811ca9f5b7c04ad. --- 1.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 1.txt diff --git a/1.txt b/1.txt deleted file mode 100644 index 8b137891..00000000 --- a/1.txt +++ /dev/null @@ -1 +0,0 @@ -