Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Selector/MultipleSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ const SelectSelector: React.FC<SelectorProps> = (props) => {
className={classNames(`${selectionPrefixCls}-item`, {
[`${selectionPrefixCls}-item-disabled`]: itemDisabled,
})}
title={
typeof content === 'string' || typeof content === 'number'
? content.toString()
: undefined
}
>
<span className={`${selectionPrefixCls}-item-content`}>{content}</span>
{closable && (
Expand Down
41 changes: 19 additions & 22 deletions tests/Multiple.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,7 @@ describe('Select.Multiple', () => {
);

toggleOpen(wrapper);
wrapper
.find('div.rc-select-item-option')
.at(1)
.simulate('mouseMove');
wrapper.find('div.rc-select-item-option').at(1).simulate('mouseMove');

wrapper.find('input').simulate('keyDown', { which: KeyCode.ENTER });
expectOpen(wrapper);
Expand All @@ -283,16 +280,10 @@ describe('Select.Multiple', () => {
);

toggleOpen(wrapper);
wrapper
.find('div.rc-select-item-option')
.first()
.simulate('mousemove');
wrapper.find('div.rc-select-item-option').first().simulate('mousemove');
wrapper.find('input').simulate('keyDown', { which: KeyCode.ENTER });

wrapper
.find('div.rc-select-item-option')
.first()
.simulate('mousemove');
wrapper.find('div.rc-select-item-option').first().simulate('mousemove');
wrapper.find('input').simulate('keyDown', { which: KeyCode.ENTER });

expect(wrapper.find('Selector').props().values).toEqual([]);
Expand Down Expand Up @@ -448,18 +439,24 @@ describe('Select.Multiple', () => {
const wrapper = mount(
<Select mode="multiple" options={[{ value: 'bamboo' }, { value: 'light' }]} tabIndex={0} />,
);
expect(
wrapper
.find('.rc-select')
.getDOMNode()
.getAttribute('tabindex'),
).toBeNull();
expect(wrapper.find('.rc-select').getDOMNode().getAttribute('tabindex')).toBeNull();

expect(
wrapper
.find('input.rc-select-selection-search-input')
.getDOMNode()
.getAttribute('tabindex'),
wrapper.find('input.rc-select-selection-search-input').getDOMNode().getAttribute('tabindex'),
).toBe('0');
});

it('should render title defaultly', () => {
const wrapper = mount(
<Select mode="multiple" options={[{ value: 'title' }]} value={['title']} />,
);
expect(wrapper.find('.rc-select-selection-item').first().prop('title')).toBe('title');
});

it('should not render title defaultly when label is ReactNode', () => {
const wrapper = mount(
<Select mode="multiple" options={[{ value: '1', label: <div>label</div> }]} value={['1']} />,
);
expect(wrapper.find('.rc-select-selection-item').first().prop('title')).toBe(undefined);
});
});
6 changes: 6 additions & 0 deletions tests/__snapshots__/Multiple.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ exports[`Select.Multiple render truncates tags by maxTagCount and show maxTagPla
>
<span
class="rc-select-selection-item"
title="One"
>
<span
class="rc-select-selection-item-content"
Expand All @@ -92,6 +93,7 @@ exports[`Select.Multiple render truncates tags by maxTagCount and show maxTagPla
>
<span
class="rc-select-selection-item"
title="Two"
>
<span
class="rc-select-selection-item-content"
Expand Down Expand Up @@ -181,6 +183,7 @@ exports[`Select.Multiple render truncates tags by maxTagCount and show maxTagPla
>
<span
class="rc-select-selection-item"
title="One"
>
<span
class="rc-select-selection-item-content"
Expand All @@ -207,6 +210,7 @@ exports[`Select.Multiple render truncates tags by maxTagCount and show maxTagPla
>
<span
class="rc-select-selection-item"
title="Two"
>
<span
class="rc-select-selection-item-content"
Expand Down Expand Up @@ -296,6 +300,7 @@ exports[`Select.Multiple render truncates values by maxTagTextLength 1`] = `
>
<span
class="rc-select-selection-item"
title="On..."
>
<span
class="rc-select-selection-item-content"
Expand All @@ -322,6 +327,7 @@ exports[`Select.Multiple render truncates values by maxTagTextLength 1`] = `
>
<span
class="rc-select-selection-item"
title="Tw..."
>
<span
class="rc-select-selection-item-content"
Expand Down
8 changes: 8 additions & 0 deletions tests/__snapshots__/Tags.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ exports[`Select.Tags OptGroup renders correctly 1`] = `
>
<span
class="rc-select-selection-item"
title="Jack"
>
<span
class="rc-select-selection-item-content"
Expand All @@ -43,6 +44,7 @@ exports[`Select.Tags OptGroup renders correctly 1`] = `
>
<span
class="rc-select-selection-item"
title="foo"
>
<span
class="rc-select-selection-item-content"
Expand Down Expand Up @@ -289,6 +291,7 @@ exports[`Select.Tags render truncates tags by maxTagCount and show maxTagPlaceho
>
<span
class="rc-select-selection-item"
title="One"
>
<span
class="rc-select-selection-item-content"
Expand All @@ -315,6 +318,7 @@ exports[`Select.Tags render truncates tags by maxTagCount and show maxTagPlaceho
>
<span
class="rc-select-selection-item"
title="Two"
>
<span
class="rc-select-selection-item-content"
Expand Down Expand Up @@ -401,6 +405,7 @@ exports[`Select.Tags render truncates tags by maxTagCount and show maxTagPlaceho
>
<span
class="rc-select-selection-item"
title="One"
>
<span
class="rc-select-selection-item-content"
Expand All @@ -427,6 +432,7 @@ exports[`Select.Tags render truncates tags by maxTagCount and show maxTagPlaceho
>
<span
class="rc-select-selection-item"
title="Two"
>
<span
class="rc-select-selection-item-content"
Expand Down Expand Up @@ -513,6 +519,7 @@ exports[`Select.Tags render truncates values by maxTagTextLength 1`] = `
>
<span
class="rc-select-selection-item"
title="On..."
>
<span
class="rc-select-selection-item-content"
Expand All @@ -539,6 +546,7 @@ exports[`Select.Tags render truncates values by maxTagTextLength 1`] = `
>
<span
class="rc-select-selection-item"
title="Tw..."
>
<span
class="rc-select-selection-item-content"
Expand Down