Skip to content

Commit

Permalink
Merge pull request #5246 from Rall3n/fix-firefox-refocus
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebennett88 authored Oct 24, 2022
2 parents da617c5 + cb6393d commit 6eb82d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-hounds-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-select': patch
---

Fix re-focus of component in Firefox if being disabled while focused
9 changes: 9 additions & 0 deletions packages/react-select/src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,15 @@ export default class Select<
// ensure select state gets blurred in case Select is programmatically disabled while focused
// eslint-disable-next-line react/no-did-update-set-state
this.setState({ isFocused: false }, this.onMenuClose);
} else if (
!isFocused &&
!isDisabled &&
prevProps.isDisabled &&
this.inputRef === document.activeElement
) {
// ensure select state gets focused in case Select is programatically re-enabled while focused (Firefox)
// eslint-disable-next-line react/no-did-update-set-state
this.setState({ isFocused: true });
}

// scroll the focused option into view if necessary
Expand Down

0 comments on commit 6eb82d4

Please sign in to comment.