Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): keep icons from shrinking in flex rows

Yudhi Armyndharisee001d36ce6e
diff --git a/dashboard/src/icon-shrink.test.ts b/dashboard/src/icon-shrink.test.ts
new file mode 100644
index 000000000..1ad4d4ab5
--- /dev/null
+++ b/dashboard/src/icon-shrink.test.ts
@@ -0,0 +1,15 @@
+import { test } from 'node:test';
+import assert from 'node:assert/strict';
+import { decl, readRules } from './test-helpers/css-rules.ts';
+
+// An svg that is a flex item shrinks like any other when its row runs short of room. With a larger browser text size
+// the sidebar entries lost their icons (Number Checker and Message Tester showed none at a 24px root size), and the
+// Dashboard tile icons shrank to 7, 13, 0 and 14px; the Infrastructure card icons and the migrations check mark
+// shrank the same way. Icons keep their size.
+const rules = readRules(new URL('./index.css', import.meta.url));
+
+test('an svg icon does not shrink as a flex item', () => {
+ const icon = rules.filter(r => !r.media && r.selectors.includes('svg'));
+ assert.equal(icon.length, 1, 'expected one global svg rule');
+ assert.equal(decl(icon[0].body, 'flex-shrink'), '0');
+});
diff --git a/dashboard/src/index.css b/dashboard/src/index.css
index 1ca75a642..867489778 100644
--- a/dashboard/src/index.css
+++ b/dashboard/src/index.css
@@ -91,6 +91,12 @@ button:focus:not(:focus-visible) {
outline: none;
}
+/* Icons keep their size: an svg that is a flex item would otherwise shrink when its row runs short of room
+ (a larger browser text size left some sidebar entries and Dashboard tiles with a sliver or no icon). */
+svg {
+ flex-shrink: 0;
+}
+
html {
/* Root/overscroll background follows the app theme token, so an explicit dark theme on a
light-OS device doesn't reveal a white <html> background above/below the body (overscroll). */