Skip to content

Content area extends under navbar on iOS due to page height 100vh #21024

Closed

Description

@vursen

Description of the bug

Currently, the body and #outlet elements have their height set to 100vh, which causes the content area to extend under the navbar even when there is no overflowing content in AppLayout. This in turn causes a vertical scrollbar. The issue was originally present only in iOS Safari, but since #20836, it now also occurs in PWA:

PWA Safari
Image Image

Expected behavior

Changing height: 100vh to height: 100% as follows

- body, #outlet {
+ html, body, #outlet {
-    height: 100vh;
+    height: 100%;
     width: 100%;
     margin: 0;
}

seems to fix the issue, resulting in a more visually appealing and expected outcome:

PWA Safari
Image Image

Minimal reproducible example

package org.vaadin.example;

import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.Paragraph;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.dom.Style.Position;
import com.vaadin.flow.router.Route;

@Route(layout = MainLayout.class)
public class MainView extends VerticalLayout {

    public MainView() {
        setSizeFull();
        add(new Paragraph("Hello world"));
        getStyle().setPosition(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(Position.ABSOLUTE);
            setWidth("100px");
            setHeight("100px");
        }
    }
}

Versions

  • Vaadin / Flow version: 24.7 and earlier
  • Java version: 17
  • OS version: iOS

Activity

  1. vursen commented on Feb 21, 2025

    @vursen
    ContributorAuthor

    The current workaround suggested by @mstahv in vaadin/web-components#8449 (comment):

    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>
            """);
        }
    }
  2. added theissue type on Feb 25, 2025
  3. moved this to 🔖 Normal Priority (P2) in Vaadin Flow bugs & maintenanceon Feb 25, 2025
  4. vursen commented on Mar 12, 2025

    @vursen
    ContributorAuthor

    This issue is also reproducible on Android devices:

    height: 100vh height: 100%
    Image Image
  5. self-assigned this
    on Mar 13, 2025
  6. moved this from 🔖 Normal Priority (P2) to ✅ Closed in Vaadin Flow bugs & maintenanceon Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions