我正在开发一个聊天应用程序,我在 iOS 上的听写功能遇到了一个奇怪的问题。
这是场景:
- 用户关注输入字段并开始听写一些文本(使用 iOS 提供的本机听写)
- 现在他们单击发送按钮,该按钮创建聊天消息,清除输入文本并再次聚焦输入(以使用户能够立即编写下一条消息)。
- 但是口述似乎并没有停止。当用户再次单击输入字段时,已经发送的文本将重新出现,同时用户所说的任何内容也会显示出来。
有谁知道如何告诉 iOS 停止听写(最好使用 JavaScript,但 Swift 中的解决方案也会有所帮助)。
谢谢!杰西
最小的例子:
const input = document.getElementById('input');
const button = document.getElementById('button');
button.addEventListener('click', () => {
input.value = '';
input.focus();
})
<input id="input"/>
<button id="button">Send</button>
<ul>
<li>Open this page on iOS</li>
<li>Focus the input and start dication</li>
<li>Click send => input is cleared</li>
<li>Click on the input => text is entered again :(</li>
</ul>