Skip to content

Commit

Permalink
Merge pull request #28423 from dukenv0307/fix/28070
Browse files Browse the repository at this point in the history
Refocus when clicking on add split button
  • Loading branch information
tgolen authored Oct 2, 2023
2 parents 5865e08 + ca42b72 commit 47b495d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/components/OptionsSelector/BaseOptionsSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit 47b495d

Please sign in to comment.