Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): size full-height panels to the visible phone screen

Yudhi Armyndharis6a443529305b
diff --git a/dashboard/src/components/Layout.css b/dashboard/src/components/Layout.css
index 4d13fc0ba..adef95e7f 100644
--- a/dashboard/src/components/Layout.css
+++ b/dashboard/src/components/Layout.css
@@ -12,6 +12,8 @@
flex-direction: column;
position: fixed;
height: 100vh;
+ /* The dynamic viewport excludes a phone browser's collapsing toolbar; the line above is the fallback. */
+ height: 100dvh;
z-index: 100;
transition:
width 0.3s ease,
@@ -252,6 +254,7 @@
/* The menu grows upward from the footer, so it may be as tall as the window less the footer (up to 186px in
Arabic) and a margin. */
max-height: calc(100vh - 13rem);
+ max-height: calc(100dvh - 13rem);
overflow-y: auto;
}
@@ -287,6 +290,7 @@
left: calc(100% + 0.5rem);
bottom: 0;
max-height: calc(100vh - 9rem);
+ max-height: calc(100dvh - 9rem);
}
.logout-btn {
@@ -425,6 +429,7 @@
width: 100%;
padding-top: 56px;
height: 100vh;
+ height: 100dvh;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
diff --git a/dashboard/src/components/Layout.css.test.ts b/dashboard/src/components/Layout.css.test.ts
index 1cefca06a..dcf1b9b53 100644
--- a/dashboard/src/components/Layout.css.test.ts
+++ b/dashboard/src/components/Layout.css.test.ts
@@ -95,6 +95,28 @@ test('the language menu is bounded by the window and scrolls', () => {
assert.equal(decl(collapsed.body, 'max-height'), 'calc(100vh - 9rem)');
});
+// 100vh is the large viewport on a phone whose browser collapses its toolbar, so a full-height scroller ended behind
+// the toolbar and its last rows could not be scrolled into view. 100dvh follows the visible area; the 100vh line
+// before it is the fallback for a browser without dvh.
+const valuesOf = (body: string, prop: string): string[] =>
+ [...body.matchAll(new RegExp(`(?:^|;)\\s*${prop}\\s*:\\s*([^;]+)`, 'g'))].map(m => m[1].trim());
+
+test('the full-height sidebar and mobile scroller follow the dynamic viewport', () => {
+ const sidebar = find('.sidebar').find(r => !r.media);
+ assert.ok(sidebar, 'no base .sidebar rule');
+ assert.deepEqual(valuesOf(sidebar.body, 'height'), ['100vh', '100dvh']);
+ const scroller = find('.main-content.mobile').find(r => r.media);
+ assert.ok(scroller, 'no mobile .main-content rule');
+ assert.deepEqual(valuesOf(scroller.body, 'height'), ['100vh', '100dvh']);
+});
+
+test('the language menu is bounded by the dynamic viewport too, since it hangs off the sidebar bottom', () => {
+ const menu = find('.language-menu-list').find(r => !r.media);
+ assert.deepEqual(valuesOf(menu?.body ?? '', 'max-height'), ['calc(100vh - 13rem)', 'calc(100dvh - 13rem)']);
+ const collapsed = find('.sidebar.collapsed .language-menu-list').find(r => !r.media);
+ assert.deepEqual(valuesOf(collapsed?.body ?? '', 'max-height'), ['calc(100vh - 9rem)', 'calc(100dvh - 9rem)']);
+});
+
// The Plugins page pins its status rail with position: sticky. overflow-x: hidden makes .main-content a scroll
// container (overflow-y computes to auto), the nearest one a sticky box sticks to, and that one never scrolls, so
// the rail scrolled away with the page. clip hides the overflow without that.
diff --git a/dashboard/src/pages/Login.css b/dashboard/src/pages/Login.css
index 51bcaa2fd..fbe98831c 100644
--- a/dashboard/src/pages/Login.css
+++ b/dashboard/src/pages/Login.css
@@ -1,5 +1,7 @@
.login-container {
min-height: 100vh;
+ /* The dynamic viewport excludes a phone browser's collapsing toolbar; the line above is the fallback. */
+ min-height: 100dvh;
width: 100%;
display: flex;
flex-direction: column;
diff --git a/dashboard/src/pages/Login.responsive.test.ts b/dashboard/src/pages/Login.responsive.test.ts
index 6fad905af..d5e86e950 100644
--- a/dashboard/src/pages/Login.responsive.test.ts
+++ b/dashboard/src/pages/Login.responsive.test.ts
@@ -18,3 +18,10 @@ test('the login content centres with auto margins, which give way to scrolling',
assert.equal(decl(body('.login-container .login-card'), 'margin-top'), 'auto');
assert.equal(decl(body('.login-container .login-footer'), 'margin-bottom'), 'auto');
});
+
+// 100vh is the large viewport on a phone whose browser collapses its toolbar, so the bottom of the fixed screen sat
+// behind the toolbar. 100dvh follows the visible area; the 100vh line before it is the fallback.
+test('the login container follows the dynamic viewport height', () => {
+ const values = [...body('.login-container').matchAll(/(?:^|;)\s*min-height\s*:\s*([^;]+)/g)].map(m => m[1].trim());
+ assert.deepEqual(values, ['100vh', '100dvh']);
+});