ant-design Pressing "ESC" key doesn't close the modal when the focus is on a search select inside the modal

thtygnil  于 22天前  发布在  其他
关注(0)|答案(4)|浏览(14)

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 |

w7t8yxp5

w7t8yxp51#

Select open=true
prioritize closing Select and stop event bubbling

0lvr5msh

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?

beq87vna

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.

9q78igpj

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)

相关问题