Reproduction link
Steps to reproduce
- Click the "Open modal" button in the reproduction sandbox
- Click in the search input inside the modal, so that is has the focus
- Press the keyboard ESC key
What is expected?
The modal closes.
What is actually happening?
The modal stays open.
| Environment | Info |
| ------------ | ------------ |
| antd | undefined |
| React | 18.2.0 |
| System | Windows 10 Pro |
| Browser | Firefox 124.0.2 |
4条答案
按热度按时间w7t8yxp51#
Select open=true
prioritize closing Select and stop event bubbling
0lvr5msh2#
@wanpan11 thanks for your quick answer. I don't understand though, are suggesting a potential solution, or just explaining why it doesn't work?
beq87vna3#
@wanpan11 thanks for your quick answer. I don't understand though, are suggesting a potential solution, or just explaining why it doesn't work?
🤣🤣🤣🤣
Select the component and listen to the ESC event at the same time. When open=true, the pop-up window of the selected component will be closed first. In the demo, open is always equal to true, causing the ESC event to fail to bubble up to the Modal component and thus cannot be closed.
9q78igpj4#
I think this is not bug to fix. There would be some circumstances that pressing esc does other action except closing modal (like clearing inputs in focused input component)