Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): keep the RTL collapse toggle on screen

Yudhi Armyndharis035829135730
diff --git a/dashboard/src/components/Layout.css b/dashboard/src/components/Layout.css
index de792bbe9..05a3fe31a 100644
--- a/dashboard/src/components/Layout.css
+++ b/dashboard/src/components/Layout.css
@@ -122,10 +122,6 @@
height: 16px;
}
-.sidebar.collapsed .collapse-toggle {
- right: -14px;
-}
-
.sidebar-nav {
flex: 1;
padding: 1rem 0.75rem;
diff --git a/dashboard/src/components/Layout.css.test.ts b/dashboard/src/components/Layout.css.test.ts
index cf4eb09a0..234349d5d 100644
--- a/dashboard/src/components/Layout.css.test.ts
+++ b/dashboard/src/components/Layout.css.test.ts
@@ -135,3 +135,19 @@ test('the collapse chevron is mirrored once, by the icon Layout.tsx picks', () =
assert.equal(decl(r.body, 'transform'), undefined, `${r.selectors.join(', ')} flips the chevron again`);
}
});
+
+// A selector's weight as classes, attributes and pseudo-classes: the selectors under test carry no ids.
+const weight = (selector: string): number =>
+ (selector.match(/\.[\w-]+|\[[^\]]+\]|:[\w-]+(?:\([^)]*\))?/g) ?? []).length;
+
+test('no rule outweighs the RTL one that moves the collapse toggle to the sidebar inner edge', () => {
+ const mirror = "[dir='rtl'] .collapse-toggle";
+ assert.equal(find(mirror).length, 1, 'no RTL rule for the collapse toggle');
+ // A heavier rule that sets `right` (the collapsed sidebar once repeated the base value) wins under
+ // RTL and pushes the toggle half off the screen.
+ const heavier = all
+ .filter(r => decl(r.body, 'right') !== undefined)
+ .flatMap(r => r.selectors)
+ .filter(s => /\.collapse-toggle$/.test(s) && weight(s) >= weight(mirror) && s !== mirror);
+ assert.deepEqual(heavier, []);
+});