简体   繁体   English

按 Esc 键关闭确认对话框后无法输入文本

[英]Cannot input text after closing a confirm dialog by Esc key

After closing a confirm dialog on a page by Esc key, I cannot input any text into any text field on the page.按 Esc 键关闭页面上的确认对话框后,我无法在页面上的任何文本字段中输入任何文本。 How can I fix it?我该如何解决?

This small html should be able to reproduce the problem easily.这个小 html 应该能够轻松重现问题。

<html>
<head></head>
<body>
<input type="text">
<script>
    window.confirm('hogehoge')
</script>
</body>
</html>

Repro Steps:重现步骤:

  1. Open this html to open a confirm dialog above the page.打开此 html 以打开页面上方的确认对话框。
  2. Hit Esc key on keyboard to close the dialog.按键盘上的 Esc 键关闭对话框。
  3. Click on the text-input field on the page to try input something.单击页面上的文本输入字段以尝试输入内容。

Result:结果:

Caret doesn't show up, and cannot input anything.插入符号不显示,也无法输入任何内容。

Expected:预期的:

Can input text into the text-input field.可以在文本输入字段中输入文本。

Notes:笔记:

  • This repros on Chrome and Edge(chromium).这在 Chrome 和 Edge(铬)上重现。
  • Not repro on FireFox.不在 FireFox 上重现。
  • OS: Windows10操作系统:Windows10
  • Once the focus goes out of the window, this problem disappears.一旦焦点移出窗口,这个问题就消失了。

It seems like it's a security feature, not a bug:似乎这是一项安全功能,而不是错误:

https://www.zdnet.com/article/google-changes-how-the-escape-key-is-handled-in-chrome-to-fight-popup-ads/ https://www.zdnet.com/article/google-changes-how-the-escape-key-is-handled-in-chrome-to-fight-popup-ads/

From the article从文章

"Since users never intend to interact with the page through the ESC key, it should not trigger user activation," Google said. “由于用户从不打算通过 ESC 键与页面交互,因此不应触发用户激活,”谷歌表示。

By "user activation" they exclude things like mouse hover or swiping fingers on the screen.通过“用户激活”,他们排除了诸如鼠标悬停或在屏幕上滑动手指之类的事情。

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

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