Skip to content

Commit

Permalink
[SpeedDial] Call focus on escape (#25509)
Browse files Browse the repository at this point in the history
Co-authored-by: eps1lon <silbermann.sebastian@gmail.com>
  • Loading branch information
tanmoyopenroot and eps1lon committed Mar 27, 2021
1 parent 47db37b commit 30b31b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/material-ui/src/SpeedDial/SpeedDial.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,9 @@ const SpeedDial = React.forwardRef(function SpeedDial(inProps, ref) {

if (event.key === 'Escape') {
setOpenState(false);
actions.current[0].focus();

if (onClose) {
actions.current[0].focus();
onClose(event, 'escapeKeyDown');
}
return;
Expand Down
6 changes: 4 additions & 2 deletions packages/material-ui/src/SpeedDial/SpeedDial.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,15 @@ describe('<SpeedDial />', () => {

expect(queryByRole('tooltip')).to.equal(null);
expect(fab).to.have.attribute('aria-expanded', 'false');
expect(fab).toHaveFocus();

fab.focus();
act(() => {
clock.runAll();
});

expect(queryByRole('tooltip')).to.equal(null);
expect(fab).to.have.attribute('aria-expanded', 'true');
expect(fab).to.have.attribute('aria-expanded', 'false');
expect(fab).toHaveFocus();
});
});

Expand Down

0 comments on commit 30b31b8

Please sign in to comment.