diff --git a/src/components/OptionsSelector/BaseOptionsSelector.js b/src/components/OptionsSelector/BaseOptionsSelector.js index aa02701b1c98..52f15f502028 100755 --- a/src/components/OptionsSelector/BaseOptionsSelector.js +++ b/src/components/OptionsSelector/BaseOptionsSelector.js @@ -53,6 +53,7 @@ class BaseOptionsSelector extends Component { this.scrollToIndex = this.scrollToIndex.bind(this); this.selectRow = this.selectRow.bind(this); this.selectFocusedOption = this.selectFocusedOption.bind(this); + this.addToSelection = this.addToSelection.bind(this); this.relatedTarget = null; const allOptions = this.flattenSections(); @@ -337,6 +338,20 @@ class BaseOptionsSelector extends Component { }); } + /** + * Completes the follow-up action after clicking on multiple select button + * @param {Object} option + */ + addToSelection(option) { + if (this.props.shouldShowTextInput && this.props.shouldFocusOnSelectRow) { + this.textInput.focus(); + if (this.textInput.isFocused()) { + setSelection(this.textInput, 0, this.props.value.length); + } + } + this.props.onAddToSelection(option); + } + render() { const shouldShowFooter = !this.props.isReadOnly && (this.props.shouldShowConfirmButton || this.props.footerContent) && !(this.props.canSelectMultipleOptions && _.isEmpty(this.props.selectedOptions)); @@ -377,7 +392,7 @@ class BaseOptionsSelector extends Component { canSelectMultipleOptions={this.props.canSelectMultipleOptions} shouldShowMultipleOptionSelectorAsButton={this.props.shouldShowMultipleOptionSelectorAsButton} multipleOptionSelectorButtonText={this.props.multipleOptionSelectorButtonText} - onAddToSelection={this.props.onAddToSelection} + onAddToSelection={this.addToSelection} hideSectionHeaders={this.props.hideSectionHeaders} headerMessage={this.props.headerMessage} boldStyle={this.props.boldStyle}