Skip to content

Commit

Permalink
fix: Select should show selected icon when value is '' (react-compone…
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 authored Oct 22, 2022
1 parent eefb3e9 commit 34903a8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/OptionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, OptionListP
// https://github.com/ant-design/ant-design/issues/34975
const isSelected = React.useCallback(
(value: RawValueType) => rawValues.has(value) && mode !== 'combobox',
[mode, [...rawValues].toString()],
[mode, [...rawValues].toString(), rawValues.size],
);

// Auto scroll to item position in single mode
Expand Down
20 changes: 20 additions & 0 deletions tests/Multiple.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -600,5 +600,25 @@ describe('Select.Multiple', () => {
expect(errSpy).not.toHaveBeenCalled();
errSpy.mockRestore();
});

it('selected icon should show when value is empty', () => {
const wrapper = mount(
<Select
mode="multiple"
open
options={[
{
label: 'Bamboo',
value: '',
},
]}
/>,
);
toggleOpen(wrapper);
selectItem(wrapper, 0);
expect(wrapper.find('.rc-select-item-option-state-icon').at(0).text()).toBe('✓');
selectItem(wrapper, 0);
expect(wrapper.find('.rc-select-item-option-state-icon').at(0).text()).toBe('');
});
});
});

0 comments on commit 34903a8

Please sign in to comment.