Skip to content

Commit

Permalink
[Bugfix] guard dropdown ref
Browse files Browse the repository at this point in the history
  • Loading branch information
selvagsz committed Feb 22, 2018
1 parent dce858a commit 8e6deb6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,10 @@ export default class Select extends Component {
handleEscapePress(event) {
if (event.which === 27) {
let $target = event.target;
if (this.powerselect.contains($target) || this.dropdown.contains($target)) {
if (
this.powerselect.contains($target) ||
(this.dropdown && this.dropdown.contains($target))
) {
this.resetSearchAndClose();
this.focusField();
}
Expand All @@ -265,7 +268,12 @@ export default class Select extends Component {

handleDocumentClick(event) {
let $target = event.target;
if (!(this.powerselect.contains($target) || this.dropdown.contains(event.target))) {
if (
!(
this.powerselect.contains($target) ||
(this.dropdown && this.dropdown.contains(event.target))
)
) {
let { focused, isOpen } = this.state;
if (focused) {
this.setFocusedState(false);
Expand Down

0 comments on commit 8e6deb6

Please sign in to comment.