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 18, 2022
1 parent 24e47ca commit 3cd86e8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/modules/Dropdown/Dropdown.js
Expand Up @@ -404,10 +404,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 3cd86e8

Please sign in to comment.