Skip to content

Commit fef90c5

Browse files
committed
fix: issue-4301
1 parent 1a416c1 commit fef90c5

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/components/TeamManagement/AutocompleteInput.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class AutocompleteInput extends React.Component {
1616
const {
1717
placeholder,
1818
selectedMembers,
19-
disabled
19+
disabled,
20+
inputValue
2021
} = this.props
2122

2223
return (
@@ -27,6 +28,7 @@ class AutocompleteInput extends React.Component {
2728
showDropdownIndicator={false}
2829
createOption
2930
placeholder={placeholder}
31+
inputValue={inputValue}
3032
value={selectedMembers}
3133
onInputChange={this.props.onInputChange}
3234
onChange={this.props.onUpdate}
@@ -41,6 +43,7 @@ class AutocompleteInput extends React.Component {
4143
AutocompleteInput.defaultProps = {
4244
placeholder: 'Enter one or more user handles',
4345
selectedMembers: [],
46+
inputValue: '',
4447
disabled: false
4548
}
4649

@@ -70,6 +73,11 @@ AutocompleteInput.propTypes = {
7073
* The flag if component is disabled
7174
*/
7275
disabled: PropTypes.bool,
76+
77+
/**
78+
* The inputValue for the input field
79+
*/
80+
inputValue: PropTypes.string,
7381
}
7482

7583
export default AutocompleteInput

src/components/TeamManagement/AutocompleteInputContainer.jsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ class AutocompleteInputContainer extends React.Component {
1111
constructor(props) {
1212
super(props)
1313
this.debounceTimer = null
14+
this.state = {
15+
// field input value
16+
inputValue: ''
17+
}
1418

1519
this.clearUserSuggestions = this.clearUserSuggestions.bind(this)
1620
}
@@ -27,7 +31,11 @@ class AutocompleteInputContainer extends React.Component {
2731
}
2832
}
2933

30-
onInputChange(inputValue) {
34+
onInputChange(inputValue, reason) {
35+
// for keeping inputValue
36+
if (reason.action === 'input-blur' || reason.action === 'menu-close') {
37+
return
38+
}
3139
const indexOfSpace = inputValue.indexOf(' ')
3240
const indexOfSemiColon = inputValue.indexOf(';')
3341

@@ -36,6 +44,7 @@ class AutocompleteInputContainer extends React.Component {
3644
return ''
3745
}
3846

47+
this.setState({inputValue})
3948
if (indexOfSpace >= 1 || indexOfSemiColon >= 1 ) {
4049
inputValue = inputValue.substring(0, inputValue.length -1 )
4150
this.onUpdate([...this.props.selectedMembers, {label: inputValue, value: inputValue}])
@@ -69,9 +78,11 @@ class AutocompleteInputContainer extends React.Component {
6978
render() {
7079

7180
const { placeholder, currentUser, selectedMembers, disabled } = this.props
81+
const {inputValue} = this.state
7282

7383
return (
7484
<AutocompleteInput
85+
inputValue={inputValue}
7586
placeholder={placeholder ? placeholder:''}
7687
onInputChange={this.onInputChange.bind(this)}
7788
onUpdate={this.onUpdate.bind(this)}

0 commit comments

Comments
 (0)