| 902 | blur = this.blurInput; |
| 903 | |
| 904 | openMenu(focusOption: 'first' | 'last') { |
| 905 | const { selectValue, isFocused } = this.state; |
| 906 | const focusableOptions = this.buildFocusableOptions(); |
| 907 | let openAtIndex = focusOption === 'first' ? 0 : focusableOptions.length - 1; |
| 908 | |
| 909 | if (!this.props.isMulti) { |
| 910 | const selectedIndex = focusableOptions.indexOf(selectValue[0]); |
| 911 | if (selectedIndex > -1) { |
| 912 | openAtIndex = selectedIndex; |
| 913 | } |
| 914 | } |
| 915 | |
| 916 | // only scroll if the menu isn't already open |
| 917 | this.scrollToFocusedOptionOnUpdate = !(isFocused && this.menuListRef); |
| 918 | |
| 919 | this.setState( |
| 920 | { |
| 921 | inputIsHiddenAfterUpdate: false, |
| 922 | focusedValue: null, |
| 923 | focusedOption: focusableOptions[openAtIndex], |
| 924 | focusedOptionId: this.getFocusedOptionId(focusableOptions[openAtIndex]), |
| 925 | }, |
| 926 | () => this.onMenuOpen() |
| 927 | ); |
| 928 | } |
| 929 | |
| 930 | focusValue(direction: 'previous' | 'next') { |
| 931 | const { selectValue, focusedValue } = this.state; |