Skip to content

Commit 854f302

Browse files
vaadin-botjouniplatosha
authored
fix: ios home screen app height (#24435) (CP: 25.1) (#24467)
This PR cherry-picks changes from the original PR #24435 to branch 25.1. --- #### Original PR description > Fixes #5576 > > We can consider adding a feature to the PWA annotation later, if there are requests for that. For now, I assume this fix is enough for the majority of our users. > > The bootstrap page update makes sure the app covers the entire viewport height on iOS when opened as a standalone/home screen app. Co-authored-by: Jouni Koivuviita <jouni@vaadin.com> Co-authored-by: Anton Platonov <anton@vaadin.com>
1 parent c7a0787 commit 854f302

4 files changed

Lines changed: 22 additions & 6 deletions

File tree

‎flow-server/src/main/java/com/vaadin/flow/server/BootstrapHandler.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ private static void setupPwa(Document document, PwaRegistry registry) {
17481748
.attr(CONTENT_ATTRIBUTE, config.getThemeColor());
17491749
head.appendElement(META_TAG)
17501750
.attr("name", "apple-mobile-web-app-status-bar-style")
1751-
.attr(CONTENT_ATTRIBUTE, config.getThemeColor());
1751+
.attr(CONTENT_ATTRIBUTE, "black-translucent");
17521752

17531753
// Add manifest
17541754
head.appendElement("link").attr("rel", "manifest").attr("href",

‎flow-server/src/main/resources/com/vaadin/flow/server/frontend/index.html‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@
1313
width: 100%;
1414
margin: 0;
1515
}
16+
17+
/*
18+
Fix app height for iOS home screen apps:
19+
- 100% doesn't cover the entire screen.
20+
- 100vh would work on iOS 18 but not on iOS 17 (too tall in Safari, correct in standalone mode).
21+
- 100lvh is too tall in Safari. 100svh is too short in standalone apps.
22+
- 100dvh doesn't seem to work on first render when launched from home screen (initially like 100svh, then changes to 100lvh when you try to scroll the view).
23+
- So, we use 100% for the regular case (Safari and other browsers), and 100lvh for iOS home screen apps. Note, that the `display-mode: standalone` media query only works if the webmanifest defines `"display": "standalone"`.
24+
*/
25+
@supports (-webkit-touch-callout: none) {
26+
@media (display-mode: standalone) {
27+
html {
28+
height: 100lvh;
29+
}
30+
}
31+
}
1632
</style>
1733
<!-- index.ts is included here automatically (either by the dev server or during the build) -->
1834
</head>

‎flow-server/src/test/java/com/vaadin/flow/server/communication/IndexHtmlRequestHandlerTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ public void should_add_metaAndPwa_Inline_Elements_when_appShellPresent()
624624
elements, "apple-mobile-web-app-status-bar-style");
625625
assertTrue(appleMobileWebAppStatusBar.isPresent(),
626626
"'apple-mobile-web-app-status-bar-style' meta link should exists.");
627-
assertEquals("#ffffff",
627+
assertEquals("black-translucent",
628628
appleMobileWebAppStatusBar.get().attr("content"));
629629

630630
Optional<Element> mobileWebAppCapableElements = findFirstElementByNameAttrEqualTo(

‎flow-tests/test-pwa/src/test/java/com/vaadin/flow/pwatest/ui/PwaTestIT.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ public void testPwaResources() throws IOException {
6363
.size());
6464

6565
// test theme color for apple mobile
66-
Assert.assertEquals(1, head
67-
.findElements(By.xpath(
66+
Assert.assertEquals(1,
67+
head.findElements(By.xpath(
6868
"//meta[@name='apple-mobile-web-app-status-bar-style']"
69-
+ "[@content='" + AppShell.THEME_COLOR + "']"))
70-
.size());
69+
+ "[@content='black-translucent']"))
70+
.size());
7171
// icons test
7272
checkIcons(head.findElements(By.xpath("//link[@rel='shortcut icon']")),
7373
1);

0 commit comments

Comments
 (0)