Skip to content

AppLayout marginals look broken on iPhone 15 #8449

Closed

Description

@mstahv

Description

The UX seems to be non-optional when a Vaadin PWA (using AppLayout) is used on modern iPhone. The bottom of the screen is these days rounded and contains the "home swipe icon". Thus the bottom bar has quite little room for view title and buttons/icons. This is not only causing visual issues, but it is also hard to hit the "hamburger icon" in the bottom left corner.

In the attached screenshot it actually looks better than in real life, as the screenshot includes the "hidden pixels" because of rounded screen, but the "home swipe icon" is there. In iPhone, the hamburger icon is right at the edge of the screen and the visible focus ring is cut in half.

IMG_7116

Expected outcome

There should be more marginal for iPhones and other modern smartphones with curved screens.

Minimal reproducible example

Create an app from start.vaadin.com with AppLayout.

Steps to reproduce

Create a Vaadin PWA and open in iPhone

Environment

Vaadin version(s): 24.6.0
OS: iOS (latest)

Browsers

Safari on iOS

Activity

  1. yuriy-fix commented on Jan 9, 2025

    @yuriy-fix
    Contributor

    We need to check if iphone safe area is calculated properly within app-layout.

  2. rolfsmeds commented on Jan 9, 2025

    @rolfsmeds
    Contributor

    AppLayout should be using the `safe-area-inset-bottom´ environment property to determine how far from the viewport bottom its contents should be. Perhaps that's not working as expected.

    Possibly related: safe-area-inset-bottom

  3. vursen commented on Jan 13, 2025

    @vursen
    Contributor

    I tested the app-layout on iPhone 13 Pro and didn't notice any issues:

    ScreenRecording_01-13-2025.14-42-41_1.MP4

    Does it look different on iPhone 15?

    UPD: My bad, I missed that it required installing the app as a PWA. I can confirm the issue now.

  4. vursen commented on Jan 13, 2025

    @vursen
    Contributor

    Adding viewport-fit=cover to <meta name="viewport"> seems to fix the issue on iOS.

  5. self-assigned this
    on Jan 13, 2025
  6. added a commit that references this issue on Jan 20, 2025
    fa584e1
  7. added 2 commits that reference this issue on Jan 20, 2025
    e3b9334
    62def54
  8. 12 remaining items

  9. vursen commented on Feb 7, 2025

    @vursen
    Contributor

    Did you plan to do anything for the non-balanced lookin marginals or is it just only an issue in my old eyes?

    I agree that it looks slightly vertically misaligned now. Could you please share your example with the map component?

  10. mstahv commented on Feb 7, 2025

    @mstahv
    MemberAuthor

    Yeah, it may be now technically center in the "allowed area", but looks weird.

    I don't you want the map component (Maplibre, check directory) to complicate. Probably component with "full height" will do.

    @Route(layout = Layout.class)
    public class MainView extends VerticalLayout {
    
        public MainView() {
            setSizeFull();
            add(new Paragraph("Hello world"));
            getStyle().setPosition(Style.Position.RELATIVE);
            add(new Square(){{
                getStyle().setRight("0");
            }});
            add(new Square(){{
                getStyle().setLeft("0");
            }});
        }
    
        public class Square extends Div {
            public Square() {
                getStyle().setBackgroundColor("cyan");
                getStyle().setBorder("1px solid black");
                getStyle().setBottom("0");
                getStyle().setPosition(Style.Position.ABSOLUTE);
                setWidth("100px");
                setHeight("100px");
            }
        }
    }
    

    Installed iOs simulator from Xcode so it is easier to take screenshots 😎

    Image Image
  11. jouni commented on Feb 10, 2025

    @jouni
    Member

    Is the issue now that the blue rectangles are underneath the navbar?

  12. mstahv commented on Feb 10, 2025

    @mstahv
    MemberAuthor

    The problem is that 100% height component is more than 100% and then clipped (regression once this fix is really going to be landed).

  13. vursen commented on Feb 11, 2025

    @vursen
    Contributor

    The problem is that 100% height component is more than 100% and then clipped (regression once this fix is really going to be landed).

    Thanks, confirmed. The issue is caused by the use of 100vh instead of 100% in index.html.

  14. reopened this on Feb 11, 2025
  15. vursen commented on Feb 11, 2025

    @vursen
    Contributor

    It's debatable whether this should be considered a regression after all. Its behavior is now very similar to how it has always been in iOS Safari:

    PWA Safari
    Image Image

    Replacing height: 100% with height: 100vh changes the behavior in both PWA and iOS Safari, resulting in a more visually appealing outcome:

    PWA Safari
    Image Image

    However, given that it affects both, I'm more inclined to consider it a separate issue where a fix that could potentially be breaking for some applications.

  16. jouni commented on Feb 12, 2025

    @jouni
    Member

    Here’s what I’ve written down and implemented in StarPass:

    /* Using 100% doesn't cover the entire screen on fullscreen iOS mode (home screen app) */
    /* 100vh (and 100lvh) breaks normal iOS Safari layout (too high). 100svh is too short in fullscreen apps. */
    /* 100dvh doesn't seem to work in first render, and is still too short */
    @media all and (display-mode: standalone) {
      html {
        height: 100lvh;
      }
    }

    In addition to that, index.html has

    html,
    body,
    #outlet {
      margin: 0;
      height: 100%;
    }
  17. jouni commented on Feb 12, 2025

    @jouni
    Member

    However, given that it affects both, I'm more inclined to consider it a separate issue where a fix that could potentially be breaking for some applications.

    I consider the current behavior (height: 100vh in index.html) as a bug, as a full sized layout isn't working as expected in iOS Safari. But yeah, it’s probably a separate issue from this viewport and safe area topic.

  18. web-padawan commented on Feb 12, 2025

    @web-padawan
    Member

    One problem that I faced recently (Slack thread) is that with height: 100vh, layouts behave somewhat unexpectedly, e.g. VerticalLayout doesn’t take 100% of page height when setHeightFull() because it inherits the height from parent AppLayout and uses that, instead of having its height defined by the content. In this case 100% would work better.

  19. rolfsmeds commented on Feb 12, 2025

    @rolfsmeds
    Contributor

    Apparently dvh not working correctly is/was a known issue in iOS, but is allegedly fixed in 17.4 https://stackoverflow.com/a/76303978/298103

  20. mstahv commented on Feb 17, 2025

    @mstahv
    MemberAuthor

    I don't really understand why this would not be considered a regression 🤷‍♂️ If I now update to latest, my content is clipped and there is scrollable area as there previosly was not. With older versions it is not, like in my screenshots and those from @vursen. I'd assume also e.g. a view with grid to now have fairly broken UX with 24.6.5, or anything with something draggable&full height on the screen.

    As this proabably will be hit by others than just me as well, here is my workaround derived based on the tips by @jouni. Disclaimer: I haven't checked if this now breaks something e.g. with Android phones, maybe jouni remembers something from StarPass tunings? The odd looking marginal for the "bottom bar" is still there, but functionality is now better and the regression is fixex.

    public class Application implements AppShellConfigurator, IndexHtmlRequestListener {
    
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
    
        @Override
        public void configurePage(AppShellSettings settings) {
            AppShellConfigurator.super.configurePage(settings);
        }
    
        @EventListener
        public void hookHacks(ServiceInitEvent event) {
            event.addIndexHtmlRequestListener(this);
        }
    
        @Override
        public void modifyIndexHtmlResponse(IndexHtmlResponse indexHtmlResponse) {
            indexHtmlResponse.getDocument().head().append("""
            <style>
                html, body, #outlet { height: 100%; }
            </style>
            """);
        }
    }
    

    Probably doing similar change to index.html file works as well, but I don't have that (as the file says it is autogenerated and I (generally) want to get the latest from the release and keep my project as clean as possible.

    Alternative solution is to rever the regressing viewport change (but then the hamburger menu toggle is again "too much in the corner" and the marginals look broken in a different way.

    @Override
    public void configurePage(AppShellSettings settings) {
        AppShellConfigurator.super.configurePage(settings);
        settings.setViewport(Viewport.DEFAULT.substring(0, Viewport.DEFAULT.indexOf(", viewport-fit=cover")));
    }
    
  21. mstahv commented on Feb 17, 2025

    @mstahv
    MemberAuthor

    I tried to find a way to adjust the marginals in the "bottom navbar mode", but my CSS skills just wasn't enough. The following pretty much fixes it for iOS PWA, but then it looks crap in non-PWA and event on desktop (and probably on PWA on devices without these new fancy rounded corners). vaadin.com/docs suggests using vaadin-app-layout::part(navbar bottom), which doesn't seem to stick (bottom is an attribute, not part name 🤔), but even then I couldn't yet distinguish the PWA from others :

            vaadin-app-layout::part(navbar) {
                padding-bottom:1em;
            }
    

    Some JS hack maybe 😢

  22. vursen commented on Mar 13, 2025

    @vursen
    Contributor

    Closing this issue as completed. The page height issue will be addressed in vaadin/flow#21024.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions