reactjs/react-modal
Pressing enter key to close button closes the modal but the event is attached to opener element and reopens the modal
开放
#954 创建于 2022年6月18日
discussioneventshelp wantedmaybe bugneeds info
仓库指标
- 星标
- (7,294 个星标)
- PR 合并指标
- (PR 指标待抓取)
描述
Summary:
Steps to reproduce:
- Visit my demo on Codesandbox https://codesandbox.io/s/react-modal-vivyxc?file=/src/index.js
- Click 'Open Modal' button and press
Tab. This will focus the close button - Press
Enterthis closes the modal but reopens it. I know this is because of theonKeyUpevent listener to anchor tag but this function is needed for other purposes.
Expected behavior:
Closes modal and focus move to the opener element( in this case, anchor tag)
Link to example of issue:
Codesandbox https://codesandbox.io/s/react-modal-vivyxc?file=/src/index.js
Additional notes:
Is there a way to solve this issue without removing the onKeyUp event handler?
Thanks.