MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
444 stars 53 forks source link

Webview 2 content is getting clipped partially and doesn't resize properly to it's content height #1244

Open ranaprathap2 opened 3 years ago

ranaprathap2 commented 3 years ago

image

I want to disable the WebView2's vertical scrolling and to keep the parent element scrolling instead. So I tried to resize the webview2's height to the height of its actually rendered content.

What I observed is the Webview2's height is getting set properly to its contents height, But despite still the height being set properly the content inside the webview2 is not getting rendered fully, Instead only the partial content at the top is shown.

AB#41783474

ranaprathap2 commented 3 years ago

WebView2SampleApp.zip

You can download and run the above project,

1) Open WebView2SamplApp.sln solution file. 2) Click Preview HTML button

The Test.html page would automatically load into the WebView2 preview and you can see the content being clipped at the bottom after disabling the vertical scroll and resizing the webview2 to it's actually rendered content's height.

champnic commented 3 years ago

Hey @ranaprathap2 - Looking at your sample app (thanks for providing!) my guess is that the content is continuing to load past your 2 second delay. I would play around with setting the height on a delayed loop to see if it eventually sets the right height. Additionally, I still see the web scrollbar, which could be due to my screen's DPI and how you are getting the height of the content.

Is there a reason you don't want to use the web scrolling?

Another option would be to try disabling the vertical scrollbar using HTML/JS and executing script: https://www.geeksforgeeks.org/how-to-disable-scrolling-temporarily-using-javascript/

ranaprathap2 commented 3 years ago

Hi @champnic (thanks for your reply), We have already tried disabling webview scrolling in style using overflow: hidden, still the clipping issue would occur. Also, I can get the height of the webview's content by passing document.body.scrollHeight.toString()"to ExecuteScript async method.

We have planned to construct a list view where each list view item would have a webview, So in this case disabling the webview scrolling, resetting webview's height to its content and letting the parent list view's scroll viewer to control scrolling would be a better UX(User experience) here in our case.

ranaprathap2 commented 1 year ago

Hi Guys, Any update on this ?

champnic commented 1 year ago

Hey @ranaprathap2 - no update here, we haven't had a chance to look into this one closely yet.