Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebViewPanel.reveal doesn't focus the tab if already visible #48246

Closed
eamodio opened this issue Apr 20, 2018 · 5 comments
Closed

WebViewPanel.reveal doesn't focus the tab if already visible #48246

eamodio opened this issue Apr 20, 2018 · 5 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded webview Webview issues
Milestone

Comments

@eamodio
Copy link
Contributor

eamodio commented Apr 20, 2018

When I have a WebViewPanel open and visible but not active in ViewColumn.Three and I call WebViewPanel.reveal(ViewColumn.Three); the panel doesn't become the active editor.

/cc @mjbvz

Originally from #43713 (comment)

@eamodio
Copy link
Contributor Author

eamodio commented Apr 20, 2018

While not directly related I also noticed while listening for WebViewPanel.onDidChangeViewState it never fires when it becomes visible when it was hidden behind another tab but doesn't become active.

For example, you have 2 tabs in column 1 -- tab 1 (hidden) is the webview, and tab 2 (visible) is another file, and then you have a tab in column 2 that is currently active. If you click the close X on tab 2, which will cause the webview to become visible, but not become active, because the tab in col 2 is still active. No event gets fired.

@jrieken jrieken removed their assignment Apr 20, 2018
@mjbvz
Copy link
Collaborator

mjbvz commented Apr 20, 2018

I can't repo this in the latest insiders:

apr-20-2018 12-02-11

import * as vscode from 'vscode';
import { join } from 'path';

const catCounterViewType = 'catCounter';

export function activate(context: vscode.ExtensionContext) {
    const cat = vscode.Uri.file(join(context.extensionPath,'media', 'cat.gif')).with({ scheme: 'vscode-resource' })

    let panel: any;

    let disposable = vscode.commands.registerCommand('cat.startCounting', () => {
        if (!panel) {
            panel = (vscode.window as any).createWebviewPanel(catCounterViewType, 'Cat Counter', vscode.ViewColumn.Three, { });
        }
        panel.reveal(vscode.ViewColumn.Three);
        panel.webview.html = contentFor(cat, 0);
    });

    context.subscriptions.push(disposable);
}

function contentFor(cat: vscode.Uri, count: number) {
    return `
        <img src="${cat}" width="200" />
        <b id='counter' style="font-family: 'Comic Sans MS'; font-size: 96px; color: hotpink;"></b>

        <script>
            const counter = document.getElementById('counter');
            let count = ${count};

            setInterval(() => {
                const c = count++
                counter.innerText = c;
                window.parent.postMessage({ count: c }, '*');
            }, 100)
        </script>`;
}

The webview always becomes active/focused after reveal. Please share some example code

@eamodio
Copy link
Contributor Author

eamodio commented Apr 21, 2018

When I run that exact same code on the latest insiders I don't see the behavior you see. What OS are you on? I'm on Windows 10.

@mjbvz
Copy link
Collaborator

mjbvz commented Apr 23, 2018

Ok, I was testing on macos. Let me test on windows again.

I also just pushed some fixed for view state events not being fired. Those should be in the next insiders build

@mjbvz mjbvz added this to the April 2018 milestone Apr 23, 2018
@mjbvz mjbvz added webview Webview issues bug Issue identified by VS Code Team member as probable bug labels Apr 23, 2018
@mjbvz
Copy link
Collaborator

mjbvz commented Apr 26, 2018

I just tested this on windows in the latest insiders build. All appears to be working now. Let me know if you still see this issue with the latest insiders

@mjbvz mjbvz closed this as completed Apr 26, 2018
@dbaeumer dbaeumer added the verified Verification succeeded label Apr 27, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded webview Webview issues
Projects
None yet
Development

No branches or pull requests

4 participants