更新 `enterKeyHint` 会重置 Chrome Android 上的输入值

发布于 2025-01-12 07:33:04 字数 1166 浏览 1 评论 0原文

我正在更新 enterKeyHint 动态地在自动完成库中。当存在活动项目时,Enter 键应使用“go”(暗示按 Enter 导航到该项目的链接),而当不存在时(无查询,没有结果),Enter 键应使用“搜索”。

此 DOM 更新在大多数移动浏览器上都可以正常工作,Chrome Android 除外。更新发生时,输入值将被清除。

我已经单独重现了该问题。更新从 5 个字符开始。

以下是 Galaxy S9 上的快速预览:

使用 Firefox Android,Enter 键的标签会按预期更新,并且输入值不会更改。

预期行为在 Firefox Android 上

对于 Chrome Android,Enter 键会更新,但输入值会重置(导致 Enter 键发生新的更新等)

<一个href="https://i.sstatic.net/ujFtR.gif" rel="nofollow noreferrer">Chrome 上的意外行为Android

我怀疑移动浏览器实现该规范的方式不一致,因为在 Safari iOS、Chrome iOS 和 Firefox Android 上一切都按预期工作。但是,我在网上找不到任何内容,以前似乎没有报道过这种行为(我认为更新此属性不太常见)。

有人遇到过这个问题,或者理解它吗?提前致谢!

I'm updating the value of enterKeyHint dynamically in an autocomplete library. When there's a active item, the Enter key should use "go" (to hint that hitting Enter navigates to the item's link) and when there isn't (no query, no results), the Enter key should use "search".

This DOM updates works fine on most mobile browsers, except on Chrome Android. When the update happens, the input value is cleared.

I've reproduced the issue in isolation. The update kicks in at 5 characters.

Here are quick previews on a Galaxy S9:

With Firefox Android, the Enter key's label updates as expected and the input value doesn't change.

Expected behavior on Firefox Android

With Chrome Android, the Enter key updates but the input value is reset (causing new updates to the Enter key, etc.)

Unexpected behavior on Chrome Android

I'm suspecting an inconsistency between how mobile browsers implement the spec, since everything works as expected on Safari iOS, Chrome iOS and Firefox Android. However, I couldn't find anything online, it doesn't seem like this behavior has been reported before (I assume updating this propery isn't too commonplace).

Has anyone ever faced this issue, or understands it? Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文