Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): mirror physical sides under right-to-left

Yudhi Armyndharis19c6009e8e17
diff --git a/dashboard/src/components/FilterBuilder.css b/dashboard/src/components/FilterBuilder.css
index 763c12bb4..efba972f0 100644
--- a/dashboard/src/components/FilterBuilder.css
+++ b/dashboard/src/components/FilterBuilder.css
@@ -280,7 +280,7 @@
border: none;
background: transparent;
cursor: pointer;
- text-align: left;
+ text-align: start;
}
.chips-suggestion:hover {
diff --git a/dashboard/src/components/GlobalSearch.css b/dashboard/src/components/GlobalSearch.css
index f8849786a..a34cb1d0d 100644
--- a/dashboard/src/components/GlobalSearch.css
+++ b/dashboard/src/components/GlobalSearch.css
@@ -68,7 +68,7 @@
background: transparent;
border: 0;
border-bottom: 1px solid var(--border);
- text-align: left;
+ text-align: start;
cursor: pointer;
font: inherit;
color: var(--text-primary);
diff --git a/dashboard/src/components/PluginInstances.css b/dashboard/src/components/PluginInstances.css
index 92224ba9c..1ca0af75a 100644
--- a/dashboard/src/components/PluginInstances.css
+++ b/dashboard/src/components/PluginInstances.css
@@ -78,7 +78,7 @@
.plugin-instances .pi-actions {
display: flex;
gap: 0.25rem;
- margin-left: auto;
+ margin-inline-start: auto;
}
.plugin-instances .pi-hint {
font-size: 0.8rem;
diff --git a/dashboard/src/components/Toast.css b/dashboard/src/components/Toast.css
index aa29f9498..9f8860ecb 100644
--- a/dashboard/src/components/Toast.css
+++ b/dashboard/src/components/Toast.css
@@ -19,7 +19,7 @@
box-shadow:
0 10px 40px rgba(0, 0, 0, 0.12),
0 4px 12px rgba(0, 0, 0, 0.08);
- border-left: 4px solid;
+ border-inline-start: 4px solid;
animation: slideIn 0.3s ease-out;
}
diff --git a/dashboard/src/pages/Infrastructure.css b/dashboard/src/pages/Infrastructure.css
index b9056fb31..5adb05f54 100644
--- a/dashboard/src/pages/Infrastructure.css
+++ b/dashboard/src/pages/Infrastructure.css
@@ -542,7 +542,7 @@
.infrastructure-page .migration-warning {
display: flex;
gap: 0.6rem;
- text-align: left;
+ text-align: start;
margin: 0 0 1.5rem;
padding: 0.85rem 1rem;
border-radius: 8px;
diff --git a/dashboard/src/pages/Login.css b/dashboard/src/pages/Login.css
index fbe98831c..7ee9a0849 100644
--- a/dashboard/src/pages/Login.css
+++ b/dashboard/src/pages/Login.css
@@ -99,7 +99,8 @@
.login-container .input-wrapper input {
width: 100%;
- padding: 0.75rem 3rem 0.75rem 1rem;
+ padding: 0.75rem 1rem;
+ padding-inline-end: 3rem;
font-size: 1rem;
border: 1px solid var(--border);
border-radius: var(--radius);
@@ -121,7 +122,7 @@
.login-container .toggle-visibility {
position: absolute;
- right: 0.75rem;
+ inset-inline-end: 0.75rem;
top: 50%;
transform: translateY(-50%);
background: none;
@@ -228,7 +229,8 @@
}
.login-container .input-wrapper input {
- padding: 0.625rem 2.5rem 0.625rem 0.875rem;
+ padding: 0.625rem 0.875rem;
+ padding-inline-end: 2.5rem;
font-size: 0.9375rem;
}
diff --git a/dashboard/src/pages/Logs.css b/dashboard/src/pages/Logs.css
index 67fe9dc79..38172c7e6 100644
--- a/dashboard/src/pages/Logs.css
+++ b/dashboard/src/pages/Logs.css
@@ -283,7 +283,7 @@
display: flex;
flex-direction: column;
align-items: flex-start;
- text-align: left;
+ text-align: start;
gap: 0.5rem;
padding: 1rem;
background: var(--bg-white);
@@ -293,11 +293,11 @@
margin-bottom: 0.75rem;
}
- /* Cells inherit centering from the desktop grid; force a left-aligned, scannable card. */
+ /* Cells inherit centering from the desktop grid; force a start-aligned, scannable card. */
.logs-page .logs-table .table-row:not(.header) > span {
width: 100%;
justify-content: flex-start;
- text-align: left;
+ text-align: start;
}
.logs-page .logs-table .table-row:not(.header):hover {
diff --git a/dashboard/src/pages/MessageTester.css b/dashboard/src/pages/MessageTester.css
index 56ba936ff..7c19b4e07 100644
--- a/dashboard/src/pages/MessageTester.css
+++ b/dashboard/src/pages/MessageTester.css
@@ -102,7 +102,7 @@
}
.message-tester .toggle-group button:first-child {
- border-right: 1px solid var(--border);
+ border-inline-end: 1px solid var(--border);
}
.message-tester .toggle-group button.active {
diff --git a/dashboard/src/pages/Plugins.css b/dashboard/src/pages/Plugins.css
index ab54ffaa9..d51b857a2 100644
--- a/dashboard/src/pages/Plugins.css
+++ b/dashboard/src/pages/Plugins.css
@@ -106,7 +106,7 @@
display: inline-flex;
align-items: center;
gap: 3px;
- margin-left: 8px;
+ margin-inline-start: 8px;
padding: 0.0625rem 0.4375rem;
font-size: 0.6875rem;
font-weight: 600;
@@ -129,7 +129,7 @@
min-width: 1.25rem;
height: 1.25rem;
padding: 0 0.3125rem;
- margin-left: 6px;
+ margin-inline-start: 6px;
font-size: 0.6875rem;
font-weight: 700;
color: var(--primary-text, #17813e);
@@ -418,8 +418,8 @@
.plugins-page .config-form .config-array-row-body {
flex: 1;
min-width: 0;
- border-left: 2px solid var(--border);
- padding-left: 0.75rem;
+ border-inline-start: 2px solid var(--border);
+ padding-inline-start: 0.75rem;
}
.plugins-page .config-form .config-array-remove {
@@ -975,7 +975,8 @@
display: flex;
flex-direction: column;
gap: 0.25rem;
- margin: 0.25rem 0 0.75rem 1.5rem;
+ margin: 0.25rem 0 0.75rem;
+ margin-inline-start: 1.5rem;
max-height: 180px;
overflow-y: auto;
}
@@ -990,7 +991,8 @@
}
.plugins-page .sessions-empty {
- margin: 0.25rem 0 0.75rem 1.5rem;
+ margin: 0.25rem 0 0.75rem;
+ margin-inline-start: 1.5rem;
font-size: 0.8125rem;
color: var(--text-muted);
}
diff --git a/dashboard/src/pages/rtl-sides.test.ts b/dashboard/src/pages/rtl-sides.test.ts
index dfc85abe7..35234988a 100644
--- a/dashboard/src/pages/rtl-sides.test.ts
+++ b/dashboard/src/pages/rtl-sides.test.ts
@@ -1,6 +1,8 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
-import { readFileSync } from 'node:fs';
+import { readFileSync, readdirSync } from 'node:fs';
+import { fileURLToPath } from 'node:url';
+import { join } from 'node:path';
// i18n/index.ts sets <html dir="rtl"> for Hebrew and Arabic. A physical left or right side in a
// margin, padding, border, corner radius or text alignment stays put when the layout mirrors, so a
@@ -29,3 +31,94 @@ test('the chats stylesheet uses logical sides only', () => {
test('the number checker stylesheet uses logical sides only', () => {
assert.deepEqual(physicalSides('./NumberChecker.css'), []);
});
+
+// The files above must hold no physical side at all. Everywhere else a physical side is fine only
+// when the layout mirrors it: the rule is written for [dir='rtl'] itself, or a [dir='rtl'] rule for the
+// same selector sets the other side. Besides the single-side properties this also reads the shorthands,
+// where a 4-value margin or padding with unequal left and right, or a border-radius whose left and
+// right corners differ, hides a side.
+const SRC = join(fileURLToPath(new URL('.', import.meta.url)), '..');
+const SIDE_PROPERTY =
+ /^(?:(?:margin|padding)-(?:left|right)|border-(?:left|right)(?:-(?:width|style|color))?|border-(?:top|bottom)-(?:left|right)-radius)$/;
+
+// Whitespace separated values, keeping var(...) and calc(...) whole.
+function values(value: string): string[] {
+ return value.replace(/\s*!important\s*$/, '').match(/(?:[^\s(]|\([^)]*\))+/g) ?? [];
+}
+
+function hidesSide(property: string, value: string): boolean {
+ if (SIDE_PROPERTY.test(property)) return true;
+ if (property === 'text-align') return /^(?:left|right)$/.test(value.trim());
+ const v = values(value);
+ if (property === 'margin' || property === 'padding') return v.length === 4 && v[1] !== v[3];
+ if (property === 'border-radius') {
+ // Corners in order top-left, top-right, bottom-right, bottom-left; a shorter list repeats.
+ const [tl, tr = tl, br = tl, bl = tr] = values(value.split('/')[0]);
+ return tl !== tr || bl !== br;
+ }
+ return false;
+}
+
+function stylesheets(dir = SRC): string[] {
+ return readdirSync(dir, { withFileTypes: true }).flatMap(entry => {
+ const full = join(dir, entry.name);
+ if (entry.isDirectory()) return stylesheets(full);
+ return entry.name.endsWith('.css') ? [full] : [];
+ });
+}
+
+function unmirroredSides(full: string): string[] {
+ // Blank out comments but keep their line breaks, so a reported line number matches the file.
+ const css = readFileSync(full, 'utf8').replace(/\/\*[\s\S]*?\*\//g, comment => comment.replace(/[^\n]/g, ''));
+ const rules = [...css.matchAll(/([^{}]+)\{([^{}]*)\}/g)].map(m => ({
+ selectors: m[1].split(',').map(s => s.trim().replace(/\s+/g, ' ').replace(/"/g, "'")),
+ body: m[2],
+ at: m.index + m[1].length + 1,
+ }));
+ const known = new Set(rules.flatMap(r => r.selectors));
+ const mirrored = (selector: string): boolean =>
+ selector.startsWith("[dir='rtl']") || known.has(`[dir='rtl'] ${selector}`);
+ const found: string[] = [];
+ for (const rule of rules) {
+ if (rule.selectors.every(mirrored)) continue;
+ let offset = 0;
+ for (const declaration of rule.body.split(';')) {
+ const [property, ...rest] = declaration.split(':');
+ const value = rest.join(':');
+ if (property && hidesSide(property.trim(), value)) {
+ const line = css.slice(0, rule.at + offset + declaration.search(/\S|$/)).split('\n').length;
+ found.push(`${full.slice(SRC.length + 1)}:${line}: ${rule.selectors.join(', ')} { ${declaration.trim()} }`);
+ }
+ offset += declaration.length + 1;
+ }
+ }
+ return found;
+}
+
+test('every stylesheet either mirrors a physical side under RTL or uses logical ones', () => {
+ const files = stylesheets();
+ assert.ok(files.length >= 20, `only ${files.length} stylesheets found`);
+ assert.deepEqual(files.flatMap(unmirroredSides), []);
+});
+
+test('the side detector reads single-side properties and shorthands', () => {
+ const physical: [string, string][] = [
+ ['margin-left', '8px'],
+ ['border-right', '1px solid red'],
+ ['text-align', 'left'],
+ ['margin', '0.25rem 0 0.75rem 1.5rem'],
+ ['padding', '0.75rem 3rem 0.75rem 1rem'],
+ ['border-radius', '12px 12px 12px 4px'],
+ ['border-radius', '12px 4px'],
+ ];
+ const neutral: [string, string][] = [
+ ['margin', '0 auto'],
+ ['padding', '1rem 2rem 1rem 2rem'],
+ ['text-align', 'start'],
+ ['border-radius', '16px 16px 0 0'],
+ ['border-top', '1px solid red'],
+ ['margin-inline-start', '8px'],
+ ];
+ for (const [property, value] of physical) assert.ok(hidesSide(property, value), `${property}: ${value}`);
+ for (const [property, value] of neutral) assert.ok(!hidesSide(property, value), `${property}: ${value}`);
+});