Skip to content

Commit 34903a8

Browse files
authored
fix: Select should show selected icon when value is '' (#847)
close ant-design/ant-design#38150
1 parent eefb3e9 commit 34903a8

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/OptionList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, OptionListP
120120
// https://github.com/ant-design/ant-design/issues/34975
121121
const isSelected = React.useCallback(
122122
(value: RawValueType) => rawValues.has(value) && mode !== 'combobox',
123-
[mode, [...rawValues].toString()],
123+
[mode, [...rawValues].toString(), rawValues.size],
124124
);
125125

126126
// Auto scroll to item position in single mode

tests/Multiple.test.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,5 +600,25 @@ describe('Select.Multiple', () => {
600600
expect(errSpy).not.toHaveBeenCalled();
601601
errSpy.mockRestore();
602602
});
603+
604+
it('selected icon should show when value is empty', () => {
605+
const wrapper = mount(
606+
<Select
607+
mode="multiple"
608+
open
609+
options={[
610+
{
611+
label: 'Bamboo',
612+
value: '',
613+
},
614+
]}
615+
/>,
616+
);
617+
toggleOpen(wrapper);
618+
selectItem(wrapper, 0);
619+
expect(wrapper.find('.rc-select-item-option-state-icon').at(0).text()).toBe('✓');
620+
selectItem(wrapper, 0);
621+
expect(wrapper.find('.rc-select-item-option-state-icon').at(0).text()).toBe('');
622+
});
603623
});
604624
});

0 commit comments

Comments
 (0)