Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Search focus lost compositing status #548

Merged
merged 2 commits into from Sep 17, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions examples/single.tsx
Expand Up @@ -66,15 +66,14 @@ class Test extends React.Component {
id="my-select"
value={value}
placeholder="placeholder"
showSearch={false}
showSearch
style={{ width: 500 }}
onBlur={this.onBlur}
onFocus={this.onFocus}
onSearch={this.onSearch}
allowClear
optionFilterProp="text"
onChange={this.onChange}
backfill
onPopupScroll={() => {
console.log('Scroll!');
}}
Expand Down
2 changes: 1 addition & 1 deletion src/Selector/SingleSelector.tsx
Expand Up @@ -40,7 +40,7 @@ const SingleSelector: React.FC<SelectorProps> = props => {
const [inputChanged, setInputChanged] = React.useState(false);

const combobox = mode === 'combobox';
const inputEditable = combobox || (showSearch && open);
const inputEditable = combobox || showSearch;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

初始状态的 search input 就应该是 editable 状态,否则触发搜索后,输入法状态会被中断。

const item = values[0];

let inputValue: string = searchValue || '';
Expand Down
15 changes: 15 additions & 0 deletions tests/Select.test.tsx
Expand Up @@ -243,6 +243,21 @@ describe('Select.Basic', () => {
expect(findSelection(wrapper).text()).toBe('1');
});

it('search input should be editable initially', () => {
const wrapper = mount(
<Select showSearch>
<Option value="1">One</Option>
<Option value="2">Two</Option>
</Select>,
);
expect(
wrapper
.find('input')
.getDOMNode()
.getAttribute('readonly'),
).toBeFalsy();
});

it('filter options by "value" prop by default', () => {
const wrapper = mount(
<Select showSearch>
Expand Down
15 changes: 0 additions & 15 deletions tests/__snapshots__/Select.test.tsx.snap
Expand Up @@ -254,11 +254,8 @@ exports[`Select.Basic render renders aria-attributes correctly 1`] = `
aria-owns="undefined_list"
autocomplete="off"
class="antd-selection-search-input"
readonly=""
role="combobox"
style="opacity:0"
type="search"
unselectable="on"
value=""
/>
</span>
Expand Down Expand Up @@ -312,11 +309,8 @@ exports[`Select.Basic render renders correctly 1`] = `
aria-owns="undefined_list"
autocomplete="off"
class="antd-selection-search-input"
readonly=""
role="combobox"
style="opacity:0"
type="search"
unselectable="on"
value=""
/>
</span>
Expand Down Expand Up @@ -372,11 +366,8 @@ exports[`Select.Basic render renders data-attributes correctly 1`] = `
aria-owns="undefined_list"
autocomplete="off"
class="antd-selection-search-input"
readonly=""
role="combobox"
style="opacity:0"
type="search"
unselectable="on"
value=""
/>
</span>
Expand Down Expand Up @@ -432,11 +423,8 @@ exports[`Select.Basic render renders disabled select correctly 1`] = `
autocomplete="off"
class="antd-selection-search-input"
disabled=""
readonly=""
role="combobox"
style="opacity:0"
type="search"
unselectable="on"
value=""
/>
</span>
Expand Down Expand Up @@ -663,11 +651,8 @@ exports[`Select.Basic render renders role prop correctly 1`] = `
aria-owns="undefined_list"
autocomplete="off"
class="antd-selection-search-input"
readonly=""
role="button"
style="opacity:0"
type="search"
unselectable="on"
value=""
/>
</span>
Expand Down