切换网页视图时输入无法聚焦

我创建了一个简单的演示,并使用webview官方实例进行了修改,请帮助查看此问题: https://github.com/roguexiaohuihui/input-focus

演示内容

1,运行Cat Coding: Start cat coding session创建Web视图。

第一次创建网络视图时,焦点是正常的

2,再次运行Cat Coding: Start cat coding session以创建Web视图。

焦点正常

3,在步骤1中切换到网络视图,此焦点无法正常工作

我听了切换事件,并向网络发送了一条消息以使其成为焦点,但是焦点没有起作用

    this._panel.onDidChangeViewState(
        e => {
            if (this._panel.visible) {
                this._panel.webview.postMessage({ command: 'showFocus' });
                this._update();
            }
        },null,this._disposables
    );

media / main.js:

var input = document.getElementById('input_1')
input.focus()
window.addEventListener('message',event => {
    const message = event.data
    switch (message.command) {
        case 'showFocus':
            console.log('showFocus')
            console.log('input:',input)
            input.focus()  //It doesn't work here
            break
    }
})

vscode社区问题地址:

https://github.com/microsoft/vscode/issues/84216

问题: 当切换Web视图时,插件会通过消息将信号发送到Web视图,并主动要求Web视图的输入再次聚焦。鼠标单击屏幕后,输入不再是焦点

xinfeifei1 回答:切换网页视图时输入无法聚焦

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3125084.html

大家都在问