Skip to content

Commit

Permalink
fix(Dropdown): Keep open dropdown focused on mousedown
Browse files Browse the repository at this point in the history
Ensure that dropdown focus is not taken over by mousedown propagation.
Otherwise, this could cause the dropdown from remaining open after onClick
option.
  • Loading branch information
mterezac committed Feb 16, 2022
1 parent ff70355 commit 8c6cd21
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/modules/Dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,15 @@ export default class Dropdown extends Component {

handleMouseDown = (e) => {
debug('handleMouseDown()')
const { open } = this.state

this.isMouseDown = true
_.invoke(this.props, 'onMouseDown', e, this.props)
document.addEventListener('mouseup', this.handleDocumentMouseUp)

if (open) {
_.invoke(this.ref.current, 'focus')
}
}

handleDocumentMouseUp = () => {
Expand Down

0 comments on commit 8c6cd21

Please # to comment.