When closing a ModalDialog, focus is set to the last element that was focused before opening the modal.
It’s causing page to scroll to this element.
It seems like a trial to improve accessibility of modals, but for user using a mouse it produces a weird behaviour:
- User clicks on some input, focusing it,
- User performs some activities that do not change which element is focused,
- User opens a ModalDialog,
- User closes a ModalDialog,
- Input (from point 1) is focused back and the page is scrolled to it.
If no element is focused before opening a modal, but PageLayout from @atlaskit/page-layout is used, the page is scrolled up to the top.
The issue can be observed on https://atlassian.design/components/modal-dialog/examples:
- Press
Show More
in theDefault
section - Scroll down to
From
section - Open & close the modal in the
From
section
The page is scrolled up toShow More
in theDefault
section
The functionality seems important for users using keyboard to navigate on a page, but should be disabled if mouse is used to open a modal.