From 229eaefbfae9e50fc02b3f56eb0f09594edd26be Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 29 Sep 2023 10:17:26 +0700 Subject: [PATCH 1/2] refocus when clicking on add split button --- .../OptionsSelector/BaseOptionsSelector.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/OptionsSelector/BaseOptionsSelector.js b/src/components/OptionsSelector/BaseOptionsSelector.js index aa02701b1c98..313c56e20476 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,16 @@ class BaseOptionsSelector extends Component { }); } + 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 +388,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} From b8b294d6828cb7db329fab76e1b197387168e9a5 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 2 Oct 2023 22:20:16 +0700 Subject: [PATCH 2/2] add js doc --- src/components/OptionsSelector/BaseOptionsSelector.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/OptionsSelector/BaseOptionsSelector.js b/src/components/OptionsSelector/BaseOptionsSelector.js index 313c56e20476..52f15f502028 100755 --- a/src/components/OptionsSelector/BaseOptionsSelector.js +++ b/src/components/OptionsSelector/BaseOptionsSelector.js @@ -338,6 +338,10 @@ 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();