From a335afd7877488f8d7ba650a669f278c51457d9a Mon Sep 17 00:00:00 2001 From: Hrusikesh Panda Date: Wed, 11 Apr 2018 16:17:24 -0400 Subject: [PATCH] fix: Unregister event listener for simpleSelect (#88) :bug: When using simpleSelect, and having multiple instances of the component on the same page, opening dropdown content after selecting something in another dropdwon causes the previous dropdown to open as well. This happens since andleOutsideClick is still listening for changes on the previous instance. --- src/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/index.js b/src/index.js index 822e0d2f..95fae028 100644 --- a/src/index.js +++ b/src/index.js @@ -133,6 +133,10 @@ class DropdownTreeSelect extends Component { Object.assign(nextState, this.resetSearchState()) } + if (this.props.simpleSelect) { + document.removeEventListener('click', this.handleOutsideClick, false) + } + this.setState(nextState) this.notifyChange(this.treeManager.getNodeById(id), tags) }