Skip to content

Commit

Permalink
fix: multi-select input editable problem (react-component#1024)
Browse files Browse the repository at this point in the history
  • Loading branch information
nova1751 committed Mar 2, 2024
1 parent 9692325 commit c755b4d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/Selector/MultipleSelector.tsx
Expand Up @@ -86,9 +86,7 @@ const SelectSelector: React.FC<SelectorProps> = (props) => {
? searchValue
: '';
const inputEditable: boolean =
mode === 'tags' ||
(mode === 'multiple' && autoClearSearchValue === false) ||
(showSearch && (open || focused));
mode === 'tags' || (mode === 'multiple' && showSearch) || (showSearch && (open || focused));

// We measure width and set to the input immediately
useLayoutEffect(() => {
Expand Down
11 changes: 11 additions & 0 deletions tests/Multiple.test.tsx
Expand Up @@ -681,5 +681,16 @@ describe('Select.Multiple', () => {
toggleOpen(wrapper);
expect(wrapper.find('input').props().value).toBe('');
});
it('input should be readonly when autoClearSearchValue and showSearch are both false', () => {
const wrapper = mount(
<Select
mode="multiple"
autoClearSearchValue={false}
showSearch={false}
searchValue="test"
/>,
);
expect(wrapper.find('input').props().readOnly).toBe(true);
});
});
});

0 comments on commit c755b4d

Please sign in to comment.