Skip to content

Commit 2bb3f16

Browse files
authored
fix: hide placehoder if showSearch and closed (#706)
1 parent b3e80f5 commit 2bb3f16

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Selector/SingleSelector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const SingleSelector: React.FC<SelectorProps> = (props) => {
5555
}, [combobox, activeValue]);
5656

5757
// Not show text when closed expect combobox mode
58-
const hasTextInput = mode !== 'combobox' && !open ? false : !!inputValue;
58+
const hasTextInput = mode !== 'combobox' && !open && !showSearch ? false : !!inputValue;
5959

6060
const title =
6161
item && (typeof item.label === 'string' || typeof item.label === 'number')

tests/Select.test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,4 +1775,14 @@ describe('Select.Basic', () => {
17751775
wrapper.simulate('click');
17761776
expect(onClick).toHaveBeenCalled();
17771777
});
1778+
1779+
it('should hide placeholder if force closed and showSearch with searchValue', () => {
1780+
const wrapper = mount(
1781+
<Select showSearch searchValue="search" open={false} placeholder="placeholder" />,
1782+
);
1783+
expect(
1784+
(wrapper.find('.rc-select-selection-placeholder').getDOMNode() as HTMLSpanElement).style
1785+
.visibility,
1786+
).toBe('hidden');
1787+
});
17781788
});

0 commit comments

Comments
 (0)