diff --git a/packages/material-ui/src/Select/Select.test.js b/packages/material-ui/src/Select/Select.test.js index 8015bba9b84464..bd1236e472d44d 100644 --- a/packages/material-ui/src/Select/Select.test.js +++ b/packages/material-ui/src/Select/Select.test.js @@ -593,6 +593,39 @@ describe(' setOpen(false)} + value="" + > + setOpen(false)}>close + + + ); + } + const { container, getByRole } = render(); + const openSelect = container.querySelector('#open-select'); + openSelect.focus(); + fireEvent.click(openSelect); + + const option = getByRole('option'); + expect(option).to.have.focus; + fireEvent.click(option); + + expect(container.querySelectorAll('.Mui-focused').length).to.equal(0); + expect(openSelect).to.have.focus; + }); + it('should allow to control closing by passing onClose props', () => { function ControlledWrapper() { const [open, setOpen] = React.useState(false); diff --git a/packages/material-ui/src/Select/SelectInput.js b/packages/material-ui/src/Select/SelectInput.js index 86d23c13a5a6b8..79c8f921940ab6 100644 --- a/packages/material-ui/src/Select/SelectInput.js +++ b/packages/material-ui/src/Select/SelectInput.js @@ -110,11 +110,8 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) { if (onOpen) { onOpen(event); } - } else { - displayNode.focus(); - if (onClose) { - onClose(event); - } + } else if (onClose) { + onClose(event); } if (!isOpenControlled) {