Skip to content

Commit a335afd

Browse files
authored
fix: Unregister event listener for simpleSelect (#88) 🐛
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.
1 parent 334f8f9 commit a335afd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ class DropdownTreeSelect extends Component {
133133
Object.assign(nextState, this.resetSearchState())
134134
}
135135

136+
if (this.props.simpleSelect) {
137+
document.removeEventListener('click', this.handleOutsideClick, false)
138+
}
139+
136140
this.setState(nextState)
137141
this.notifyChange(this.treeManager.getNodeById(id), tags)
138142
}

0 commit comments

Comments
 (0)