Open
Description
Summary:
The logic of shouldReturnFocusAfterClose doesn't work in iOS Safari
Environment info: iphone 11, iOS 14.4.1
Steps to reproduce:
- Open the sandbox example in Safari on iOS
- Open modal by clicking on the Open modal button
- Close button by clicking on overlay space
- Focus doesn't return to the button. The button should have red background because of the focused styles)
RPReplay_Final1616944898.mp4
Expected behaviour:
The focus should return to the button. (In the sandbox example, the button should become red because of the focused styles)
Link to example of issue:
Sandbox: https://codesandbox.io/s/strange-joliot-k015k?file=/src/Modal.js:720-726
I've added focused styles to see when the button is focused(background: red
)
Additional notes:
I've found a possible workaround to set the focus manually on closing modal by the button ref. How it works(expected behaviour of this bug):
RPReplay_Final1616945612.mp4
You can find this workaround in the sandbox in commented code