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

Blazor WebView iOS Scrolling Behaves Strangely #6347

Closed
TanayParikh opened this issue Apr 21, 2022 · 5 comments · Fixed by #6432
Closed

Blazor WebView iOS Scrolling Behaves Strangely #6347

TanayParikh opened this issue Apr 21, 2022 · 5 comments · Fixed by #6432
Assignees
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView fixed-in-6.0.300-rc.3 Look for this fix in 6.0.300-rc.3! platform/iOS 🍎 s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@TanayParikh
Copy link
Contributor

TanayParikh commented Apr 21, 2022

This scrolling behavior seems off, likely just a matter of changing viewport settings:

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

Simulator Screen Recording - iPad Air (5th generation) - 2022-04-20 at 18 17 16

Simulator Screen Shot - iPad Air (5th generation) - 2022-04-20 at 18 19 52

Similar to #4996.

@TanayParikh TanayParikh added area-blazor Blazor Hybrid / Desktop, BlazorWebView platform/iOS 🍎 labels Apr 21, 2022
@TanayParikh TanayParikh changed the title Blazor WebView iOS Scrolling Blazor WebView iOS Scrolling Behaves Strangely Apr 21, 2022
@TanayParikh TanayParikh added t/bug Something isn't working s/verified Verified / Reproducible Issue ready for Engineering Triage labels Apr 21, 2022
@jfversluis
Copy link
Member

I think this is just how iOS works. With iOS you can draw behind the status bar if that's what you want. I encountered the same and wrote about it here: https://blog.verslu.is/maui/change-maui-ios-status-bar-color/

I am wondering if we should add that to the templates by default, that will also help create a more unified look-and-feel across the different platforms. It will add some platform-specific code. So if we were to add it I think we should have an easy way for users to change the statusbar color.

I think there are 3 possible solutions here:

  1. Leave as-is and leave it up to the user to implement however they want; I don't like this one, the out-of-the-box experience should be great
  2. Add the custom status bar thing I wrote to the templates; as said: we need to add an easy way to change the color, shouldn't be too hard
  3. Make the BlazorWebView take into account the size of the status bar and add a top margin so it doesn't go behind it; this will look cleaner, but the background will then probably be white and leave people wondering how to customize that.

Thoughts?

@mkArtakMSFT mkArtakMSFT added this to the 6.0.300 milestone Apr 21, 2022
@TanayParikh
Copy link
Contributor Author

TanayParikh commented Apr 22, 2022

Notice the following behavior with the iPhone notch.

image

image

this boils down to the "safe area" concept introduced with the iPhone X.

MAUI does integrate with this property, however just enabling it, enables padding for all safe areas, which doesn't match our overall formatting style:

/// <include file="../../../../docs/Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific/Page.xml" path="//Member[@MemberName='UseSafeAreaProperty']/Docs" />
public static readonly BindableProperty UseSafeAreaProperty = BindableProperty.Create("UseSafeArea", typeof(bool), typeof(Page), false);

image

image

image

image

From the git history, it looks like @PureWeen initially worked on that functionality. Do you have any tips on how we may be able to integrate Safe Areas within MAUI to prevent WebView content from overlapping the status bar / notch, while avoiding the additional padding on the other sides?

I tried manually setting the safe area insets, without luck:

		var insets = On<iOS>().SafeAreaInsets();
		insets.Bottom = 0;
		var safeareaPadding = new Thickness(insets.Left, insets.Top, insets.Right, insets.Bottom);
		On<iOS>().SetSafeAreaInsets(safeareaPadding);
		On<iOS>().SetUseSafeArea(true);

PS: From my research, using CSS to get around this issue is discouraged: https://stackoverflow.com/a/39505453/17995448

  • Given Safe Areas are a natively supported concept in iOS, I think we should be safe in terms of forward compatibility. Ie, with changing future form factors of future iOS devices, the Safe Areas concept should give us some protection that we don't produce strange formatting.

@TanayParikh
Copy link
Contributor Author

Scratch that last part about CSS; @javiercn pointed out https://webkit.org/blog/7929/designing-websites-for-iphone-x/ which looks like it may help here.

@TanayParikh
Copy link
Contributor Author

TanayParikh commented Apr 22, 2022

Currently:

image

With viewport-fit=cover:

image

We do get a bit of overlap with the notch, but it's better than the alternative. The only issue I can see is if it doesn't meet Apple's HCI guidelines, which could cause issues with App Store publishing.

@TanayParikh
Copy link
Contributor Author

TanayParikh commented Apr 25, 2022

Note, we aren't able to control the status bar color presently in MAUI; #6159

Thus, to get around the issue with dark content (date/time) and the dark blazor maui sidebar in the status bar:

image

we'd have to add some sort of element at the top to take the place of the status bar. This element should also remain in a fixed / sticky position.

This can be achieved either via HTML/CSS or via Xamarin Forms.

@TanayParikh TanayParikh assigned TanayParikh and unassigned javiercn Apr 25, 2022
TanayParikh added a commit that referenced this issue Apr 29, 2022
* Blazor Hybrid iOS Safe Areas

Fixes: #6347

* Safe Area part 2
@ghost ghost locked as resolved and limited conversation to collaborators May 30, 2022
@samhouts samhouts added the fixed-in-6.0.300-rc.3 Look for this fix in 6.0.300-rc.3! label Jul 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView fixed-in-6.0.300-rc.3 Look for this fix in 6.0.300-rc.3! platform/iOS 🍎 s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants