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], ); 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'); + }); + });