question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom Webview in explorer view placed at wrong position

See original GitHub issue

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: 1.59.0
  • OS Version: macOs 11.4

Steps to Reproduce:

  1. Install the “asm-code-lens” extension from market place (v1.8.1). It will add a custom view to the explorer view.
  2. Load some project, e.g. a type script project, but it should not matter what.
  3. Got to explorer view
  4. You should see the “HEXADECIMAL CALCULATOR” pane there.
  5. Make sure there is some other pane below and expand it
  6. Expand the “HEXADECIMAL CALCULATOR” pane. You will see the calculator contents.
  7. Now expand the pane above the “HEXADECIMAL CALCULATOR”
  8. This makes the “HEXADECIMAL CALCULATOR” pane to be moved down

Result: The contents of the “HEXADECIMAL CALCULATOR” pane is not moved. It stays in the same position, i.e. it is now overlapping the pane above the “HEXADECIMAL CALCULATOR”.

I have a screen cast which shows the behavior: webview

I also noticed that everything goes fine if the pane below the “HEXADECIMAL CALCULATOR” is not expanded. See here: webview2

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
a-stewartcommented, Aug 19, 2021

Hi,

I have noticed the same issue:

As far as I can see, is caused by the fact the webview is a child or the main element, not of the viewpane element. When the view pane position is updated layoutWebviewOverElement() in dynamicWebviewEditorOverlay.ts to move the webview to the same position as the view pane.

However, the view pane is now animated, and the layoutWebviewOverElement is called instantly, which means the webview positition is set to where the view pane starts the animation, not where it finishes the animation.

For a really basic hack, you can update the layoutWebviewOverElement method to something like this:

	public layoutWebviewOverElement(element: HTMLElement, dimension?: Dimension, animated = true) {
		if (!this.container || !this.container.parentElement) {
			return;
		}

		const frameRect = element.getBoundingClientRect();
		const containerRect = this.container.parentElement.getBoundingClientRect();
		const parentBorderTop = (containerRect.height - this.container.parentElement.clientHeight) / 2.0;
		const parentBorderLeft = (containerRect.width - this.container.parentElement.clientWidth) / 2.0;
		this.container.style.position = 'absolute';
		this.container.style.overflow = 'hidden';
		this.container.style.top = `${frameRect.top - containerRect.top - parentBorderTop}px`;
		this.container.style.left = `${frameRect.left - containerRect.left - parentBorderLeft}px`;
		this.container.style.width = `${dimension ? dimension.width : frameRect.width}px`;
		this.container.style.height = `${dimension ? dimension.height : frameRect.height}px`;

		// Hack, there is an animation that lasts about 200ms, update the webview position afterwards.
		if (animated) {
			setTimeout(() => {
				this.layoutWebviewOverElement(element, dimension, false);
			}, 200);
		}
	}

I think a better solution, though, may be to either anchor the webview to the view pane element so that it animates with it. Or to give the webview the details of the animation so that it can also animate in the same way.

0reactions
tamuratakcommented, Oct 5, 2021

Duplicate of #110450

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android WebView: handling orientation changes
Under my res folder, I have drawable-land and drawable-port to hold landscape/portrait variations, then I use R.drawable.myimagename for the ...
Read more >
WebView Class (Windows.UI.Xaml.Controls) - Microsoft Learn
The display area is constrained by the Width and Height properties. To translate, scale, skew, and rotate a WebView, use the RenderTransform property....
Read more >
Open custom VSCode WebView panel and focus input
#DevHack: Open custom VSCode WebView panel and focus input ... executeCommand('workbench.view.extension.frontmatter-explorer'); });.
Read more >
Error Messages | Maps JavaScript API - Google Developers
Certain error conditions may also occur, which result in the display of a ... Previous versions of WebView, based on Internet Explorer, are...
Read more >
Desired Capabilities - Appium
Set this capability to true to run the Emulator headless when device display is not needed to be visible. false is the default...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found