We have a requirement, where focus needs to be set on dropdown (not the child elements of dropdown) once the Modal is closed.
We are using ReactModal component, it has prop called 'shouldReturnFocusAfterClose'(when set to true) which will set focus back on button (where focus was set before modal opened) once Modal is closed.
<ReactModal
isOpen={isOpen}
shouldCloseOnOverlayClick={shouldCloseOnOverlayClick}
onRequestClose={onRequestClose}
getAppElement={getAppElement}
closeTimeoutMS={200}
contentRef={contentRef}
shouldReturnFocusAfterClose={true} >
</ReactModal>
Выше приведен код, ReactModal устанавливает фокус, как и ожидалось (устанавливает фокус на кнопку там, где она была до открытия модального режима)
*** ReactModal is setting focus as expected (setting focus on button where it was before modal is opened)
*** Once clicked(key event) on the one of the options of dropdown, Modal is opened. Our requirement is...Once it is closed, focus should be set to dropdown button instead of options of dropdown.