Skip to content
Closed
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
26 changes: 21 additions & 5 deletions src/Select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default class Select extends React.Component {
inputValue,
open,
};
this.isInputInComposition = false;
this.adjustOpenState();
}

Expand Down Expand Up @@ -153,6 +154,7 @@ export default class Select extends React.Component {
onInputChange = event => {
const { tokenSeparators } = this.props;
const val = event.target.value;
const type = event.type;
if (
isMultipleOrTags(this.props) &&
tokenSeparators &&
Expand All @@ -168,12 +170,24 @@ export default class Select extends React.Component {
this.setState({
open: true,
});

if (isCombobox(this.props)) {
this.fireChange([
{
key: val,
},
]);
if (type === 'compositionend') {
this.isInputInComposition = false;
this.fireChange([
{
key: val,
},
]);
} else if (type === 'change' && !this.isInputInComposition) {
this.fireChange([
{
key: val,
},
]);
} else {
this.isInputInComposition = true;
}
}
};

Expand Down Expand Up @@ -540,6 +554,8 @@ export default class Select extends React.Component {
this.onInputKeyDown,
inputElement.props.onKeyDown
),
onCompositionStart: this.onInputChange,
onCompositionEnd: this.onInputChange,
value: this.state.inputValue,
disabled: props.disabled,
className: inputCls,
Expand Down
2 changes: 2 additions & 0 deletions tests/__snapshots__/Select.multiple.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ exports[`Select.multiple render render animation 1`] = `
autoComplete="off"
className="rc-select-search__field"
onChange={[Function]}
onCompositionEnd={[Function]}
onCompositionStart={[Function]}
onKeyDown={[Function]}
value=""
/>
Expand Down
2 changes: 2 additions & 0 deletions tests/__snapshots__/Select.tags.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ exports[`Select.tags render render animation 1`] = `
autoComplete="off"
className="rc-select-search__field"
onChange={[Function]}
onCompositionEnd={[Function]}
onCompositionStart={[Function]}
onKeyDown={[Function]}
value=""
/>
Expand Down