Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): keep the install dialog focus order on a phone

Yudhi Armyndharisd0a1bb6e585b
diff --git a/dashboard/src/pages/Plugins.css b/dashboard/src/pages/Plugins.css
index 9c03d40dc..086f837dc 100644
--- a/dashboard/src/pages/Plugins.css
+++ b/dashboard/src/pages/Plugins.css
@@ -851,9 +851,9 @@
border-radius: 10px;
}
-/* Three-item header (title + tabs + close). On a narrow viewport the tabs take a row of their own under the
- title and the close button (flex-wrap on the header), without the standalone-row margins that would push
- the title up or leave a gap. */
+/* Three-item header (title + tabs + close), drawn in the order of its markup so that keyboard focus runs the way the
+ eye reads. On a narrow viewport the title has a row of its own (flex-wrap on the header) and the tabs share the
+ next one with the close button, without the standalone-row margins that would push the title up or leave a gap. */
.plugins-page .install-modal .modal-header {
flex-wrap: wrap;
row-gap: 0.75rem;
@@ -861,8 +861,7 @@
.plugins-page .install-modal .modal-header .install-tabs {
margin: 0;
- order: 3;
- width: 100%;
+ flex: 1 1 0;
}
/* From 700px the header is three tracks: the middle one as wide as the tabs, the outer two sharing the rest
@@ -877,8 +876,6 @@
}
.plugins-page .install-modal .modal-header .install-tabs {
- order: 0;
- width: auto;
/* Out of the row height, so a tall pill (a label that wraps) does not grow the header, and centered in
the header's padding box (1.5rem above the row, 1rem below it) as the absolute positioning it
replaces had it: 0.25rem above the center of the row. */
@@ -891,6 +888,7 @@
}
.plugins-page .install-modal .modal-header h2 {
+ flex: 1 1 100%;
min-width: 0;
/* Truncate an over-long title rather than collide with the tabs; the modal title is short by
design ("Install a plugin"), so this only ever bites an unusually long translation. */
@@ -942,6 +940,19 @@
color: var(--text-primary);
}
+/* On a phone the pill shares its row with the close button, which at 320px leaves less than two 128px tabs need, so
+ the pill and its tabs shrink and a long label wraps. */
+@media (max-width: 699.98px) {
+ .plugins-page .install-modal .modal-header .install-tabs {
+ min-width: 0;
+ }
+
+ .plugins-page .install-tab {
+ min-width: 0;
+ padding-inline: 0.6rem;
+ }
+}
+
/* Sessions tab */
.plugins-page .sessions-tab {
display: flex;
diff --git a/dashboard/src/pages/Plugins.responsive.test.ts b/dashboard/src/pages/Plugins.responsive.test.ts
index 28a3c666d..264e750d4 100644
--- a/dashboard/src/pages/Plugins.responsive.test.ts
+++ b/dashboard/src/pages/Plugins.responsive.test.ts
@@ -7,8 +7,8 @@ const rules = readRules(new URL('./Plugins.css', import.meta.url));
// The Upload/Catalog pill in the install modal header. Centred with absolute positioning it took no part in
// flex-wrap, so on a phone it was drawn over the title ("Insta" and a tab), and it took no part in sizing the
// title either, so a long translated title (Telugu) ran under it at every width. From 700px the header is three
-// tracks with the pill in the middle one, so the title is cut inside its own track; below that the pill takes a
-// row of its own.
+// tracks with the pill in the middle one, so the title is cut inside its own track; below that the title has a row
+// of its own and the pill shares the next one with the close button.
const HEADER = '.plugins-page .install-modal .modal-header';
const PILL = `${HEADER} .install-tabs`;
@@ -37,12 +37,52 @@ test('the close button stays in the end track and the title is cut inside its ow
assert.equal(decl(title.body, 'text-overflow'), 'ellipsis');
});
-test('below that the install tabs wrap to a row of their own', () => {
+// Keyboard focus follows the DOM order (title, tabs, close button), so no rule may draw the header in another order:
+// an order, a reversed flex direction or an explicit grid placement would put the close button, or a tab, where focus
+// does not go next.
+test('no rule draws the install header in a different order than its markup', () => {
+ const placed = rules.filter(
+ r =>
+ r.selectors.some(s => s === HEADER || s.startsWith(`${HEADER} `)) &&
+ ['order', 'grid-area', 'grid-row', 'grid-column', 'grid-template-areas'].some(p => decl(r.body, p) !== undefined),
+ );
+ assert.deepEqual(
+ placed.map(r => `${r.media || 'base'}: ${r.selectors.join(', ')}`),
+ [],
+ );
+ const flow = rules.filter(r => r.selectors.includes(HEADER) && /reverse/.test(decl(r.body, 'flex-direction') ?? ''));
+ assert.deepEqual(flow, []);
+});
+
+test('below 700px the title has a row of its own and the tabs share the next one with the close button', () => {
+ const title = rules.find(r => !r.media && r.selectors.includes(`${HEADER} h2`));
+ assert.ok(title, 'no title rule');
+ assert.equal(decl(title.body, 'flex'), '1 1 100%');
const base = rules.find(r => r.selectors.includes(PILL) && !r.media);
assert.ok(base, 'no base rule for the pill');
- assert.equal(decl(base.body, 'position'), undefined);
- assert.equal(decl(base.body, 'width'), '100%');
- assert.equal(decl(base.body, 'order'), '3');
+ assert.equal(decl(base.body, 'width'), undefined, 'a full-width pill would push the close button to another row');
+ assert.equal(decl(base.body, 'flex'), '1 1 0');
+ // Only on a phone: in the grid a zero minimum would let the middle track shrink below the tabs.
+ assert.equal(decl(base.body, 'min-width'), undefined);
+ const phone = rules.find(r => r.media === '@media (max-width: 699.98px)' && r.selectors.includes(PILL));
+ assert.ok(phone, 'no phone rule for the pill');
+ assert.equal(decl(phone.body, 'min-width'), '0');
+});
+
+// Each tab keeps 128px from 700px, where the header has room. On a phone the pill shares its row with the close
+// button, which at 320px leaves 244px minus the button: two 128px tabs overflowed the pill by 12px before the button
+// was counted, so the tabs shrink and their labels wrap.
+test('the tabs lose their 128px minimum below 700px', () => {
+ const tab = rules.find(
+ r => !r.media && r.selectors.includes('.plugins-page .install-tab') && decl(r.body, 'min-width'),
+ );
+ assert.ok(tab, 'no base rule for the tab');
+ assert.equal(decl(tab.body, 'min-width'), '128px');
+ const phone = rules.filter(
+ r => r.media === '@media (max-width: 699.98px)' && r.selectors.includes('.plugins-page .install-tab'),
+ );
+ assert.equal(phone.length, 1, 'expected one phone rule for the tab');
+ assert.equal(decl(phone[0].body, 'min-width'), '0');
});
// Beside the 280px status rail the card grid keeps a 320px minimum track. With the sidebar open that needs 948px