From 3cd86e8d069ec0c771fa87f1d32a3a21b9e66f42 Mon Sep 17 00:00:00 2001 From: Maria Tereza Date: Wed, 16 Feb 2022 14:17:42 -0300 Subject: [PATCH] fix(Dropdown): Keep open dropdown focused on mousedown Ensure that dropdown focus is not taken over by mousedown propagation. Otherwise, this could cause the dropdown from remaining open after onClick option. --- src/modules/Dropdown/Dropdown.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/Dropdown/Dropdown.js b/src/modules/Dropdown/Dropdown.js index ff4530ec75..eebdc73eb9 100644 --- a/src/modules/Dropdown/Dropdown.js +++ b/src/modules/Dropdown/Dropdown.js @@ -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 = () => {