简体   繁体   English

ng-boostrap:ESC 按键上的模式关闭不起作用

[英]ng-boostrap : modal dismiss on ESC keypress not working

I want to dismiss MODAL on the keypress of ESC.我想在 ESC 的按键上关闭 MODAL。 But it isn't working... As I see on ng-bootstrap docs, By default keyboard is true .但它不起作用......正如我在 ng-bootstrap 文档中看到的那样,默认情况下keyboardtrue But even it isn't working...但即使它不起作用......

I have applied ngbAutofocus on .modal-body class as I don't want default autofocus on close button because I had a animation on the focus of close button as well as animation on "ACCEPT" button .我在.modal-body类上应用了ngbAutofocus ,因为我不希望关闭按钮上的默认自动对焦,因为在关闭按钮的焦点上有动画,在“接受”按钮上有动画

I have attached the link of my code here...在这里附上了我的代码链接...

Thank you in advance先感谢您

The focus should be somewhere in the modal for esc to work.焦点应该在模式中的某个地方,以便esc工作。 I see you added ngbAutofocus directive to the div element.我看到您向div元素添加了ngbAutofocus指令。 the problem is - div is not focusable unless it has tabindex attribute.问题是 - 除非具有tabindex属性,否则div不可聚焦。 Adding this attribute will solve your problem.添加此属性将解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM