(prevProps: Props<Option, IsMulti, Group>)
| 822 | } |
| 823 | } |
| 824 | componentDidUpdate(prevProps: Props<Option, IsMulti, Group>) { |
| 825 | const { isDisabled, menuIsOpen } = this.props; |
| 826 | const { isFocused } = this.state; |
| 827 | |
| 828 | if ( |
| 829 | // ensure focus is restored correctly when the control becomes enabled |
| 830 | (isFocused && !isDisabled && prevProps.isDisabled) || |
| 831 | // ensure focus is on the Input when the menu opens |
| 832 | (isFocused && menuIsOpen && !prevProps.menuIsOpen) |
| 833 | ) { |
| 834 | this.focusInput(); |
| 835 | } |
| 836 | |
| 837 | if (isFocused && isDisabled && !prevProps.isDisabled) { |
| 838 | // ensure select state gets blurred in case Select is programmatically disabled while focused |
| 839 | // eslint-disable-next-line react/no-did-update-set-state |
| 840 | this.setState({ isFocused: false }, this.onMenuClose); |
| 841 | } else if ( |
| 842 | !isFocused && |
| 843 | !isDisabled && |
| 844 | prevProps.isDisabled && |
| 845 | this.inputRef === document.activeElement |
| 846 | ) { |
| 847 | // ensure select state gets focused in case Select is programatically re-enabled while focused (Firefox) |
| 848 | // eslint-disable-next-line react/no-did-update-set-state |
| 849 | this.setState({ isFocused: true }); |
| 850 | } |
| 851 | |
| 852 | // scroll the focused option into view if necessary |
| 853 | if ( |
| 854 | this.menuListRef && |
| 855 | this.focusedOptionRef && |
| 856 | this.scrollToFocusedOptionOnUpdate |
| 857 | ) { |
| 858 | scrollIntoView(this.menuListRef, this.focusedOptionRef); |
| 859 | this.scrollToFocusedOptionOnUpdate = false; |
| 860 | } |
| 861 | } |
| 862 | componentWillUnmount() { |
| 863 | this.stopListeningComposition(); |
| 864 | this.stopListeningToTouch(); |
nothing calls this directly
no test coverage detected