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 Feb 4, 2024
1 parent b190480 commit 51674dc
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -681,5 +681,16 @@ describe('Select.Multiple', () => {
toggleOpen(wrapper);
expect(wrapper.find('input').props().value).toBe('');
});
it('input should not 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 51674dc

Please sign in to comment.