Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): show the chevron on native selects
Yudhi Armyndharis34e59b9a3b83
diff --git a/dashboard/src/App.css b/dashboard/src/App.cssindex f19d01207..750d78d68 100644--- a/dashboard/src/App.css+++ b/dashboard/src/App.css@@ -121,7 +121,8 @@ input,select,textarea {font-family: inherit;- background: var(--bg-white);+ /* background-color, not the shorthand: the shorthand would reset the chevron index.css draws on select. */+ background-color: var(--bg-white);color: var(--text-primary);border-color: var(--border);}diff --git a/dashboard/src/components/FilterBuilder.css b/dashboard/src/components/FilterBuilder.cssindex 87b25b9fc..763c12bb4 100644--- a/dashboard/src/components/FilterBuilder.css+++ b/dashboard/src/components/FilterBuilder.css@@ -39,7 +39,7 @@padding: 0 0.5rem;border: 1px solid var(--border);border-radius: 6px;- background: var(--bg-white);+ background-color: var(--bg-white);color: var(--text-primary);font-size: 0.8125rem;}diff --git a/dashboard/src/index.css b/dashboard/src/index.cssindex 867489778..b9d4f7488 100644--- a/dashboard/src/index.css+++ b/dashboard/src/index.css@@ -119,6 +119,9 @@ select {-moz-appearance: none;width: 100%;padding: 0.75rem 2.5rem 0.75rem 1rem;+ /* The chevron below sits in the end padding; a page rule with its own padding must not take that+ room back, or a long value runs under the arrow. */+ padding-inline-end: 2.5rem !important;font-size: 0.9375rem;font-family: inherit;color: var(--text-primary);diff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.cssindex 10610be6f..9651aa783 100644--- a/dashboard/src/pages/Chats.css+++ b/dashboard/src/pages/Chats.css@@ -51,7 +51,7 @@padding: 0.625rem 0.75rem;border: 1px solid var(--border);border-radius: var(--radius, 8px);- background: var(--bg-light);+ background-color: var(--bg-light);color: var(--text-primary);font-size: 0.875rem;font-weight: 500;@@ -62,7 +62,7 @@.chats-page .session-selector:focus {border-color: var(--primary);- background: var(--bg-white);+ background-color: var(--bg-white);box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);}@@ -1760,7 +1760,7 @@padding: 0.625rem 0.75rem;border: 1px solid var(--border);border-radius: var(--radius, 8px);- background: var(--bg-light);+ background-color: var(--bg-light);color: var(--text-primary);font-size: 0.875rem;outline: none;@@ -1772,7 +1772,7 @@.chats-page .status-compose-modal input:focus,.chats-page .status-compose-modal select:focus {border-color: var(--primary);- background: var(--bg-white);+ background-color: var(--bg-white);box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);}diff --git a/dashboard/src/pages/Infrastructure.css b/dashboard/src/pages/Infrastructure.cssindex ee9cf6d61..b9056fb31 100644--- a/dashboard/src/pages/Infrastructure.css+++ b/dashboard/src/pages/Infrastructure.css@@ -193,7 +193,7 @@font-size: 0.9375rem;border: 1px solid var(--border);border-radius: var(--radius);- background: var(--bg-white);+ background-color: var(--bg-white);transition: border-color 0.2s;}diff --git a/dashboard/src/pages/MessageTester.css b/dashboard/src/pages/MessageTester.cssindex 13d50d576..56ba936ff 100644--- a/dashboard/src/pages/MessageTester.css+++ b/dashboard/src/pages/MessageTester.css@@ -59,7 +59,7 @@font-size: 0.9375rem;border: 1px solid var(--border);border-radius: var(--radius);- background: var(--bg-white);+ background-color: var(--bg-white);transition: border-color 0.2s;}diff --git a/dashboard/src/pages/NumberChecker.css b/dashboard/src/pages/NumberChecker.cssindex afcca1d6e..b96b7abad 100644--- a/dashboard/src/pages/NumberChecker.css+++ b/dashboard/src/pages/NumberChecker.css@@ -169,7 +169,7 @@font-size: 0.9375rem;border: 1px solid var(--border);border-radius: var(--radius);- background: var(--bg-white);+ background-color: var(--bg-white);color: var(--text-primary);transition:border-color 0.2s,diff --git a/dashboard/src/pages/Plugins.css b/dashboard/src/pages/Plugins.cssindex 06b06141c..ab54ffaa9 100644--- a/dashboard/src/pages/Plugins.css+++ b/dashboard/src/pages/Plugins.css@@ -358,7 +358,7 @@border: 1px solid var(--border);border-radius: 8px;font-size: 0.9375rem;- background: var(--bg-light);+ background-color: var(--bg-light);transition: all 0.2s;box-sizing: border-box;}@@ -374,7 +374,7 @@.plugins-page .config-form .form-group textarea:focus {outline: none;border-color: var(--primary);- background: var(--bg-white);+ background-color: var(--bg-white);box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);}@@ -1000,7 +1000,7 @@padding: 0.6rem 0.85rem;border: 1px solid var(--border);border-radius: 8px;- background: var(--bg-light);+ background-color: var(--bg-light);font-size: 0.9375rem;margin-bottom: 1rem;box-sizing: border-box;diff --git a/dashboard/src/select-chevron.test.ts b/dashboard/src/select-chevron.test.tsnew file mode 100644index 000000000..91ed79114--- /dev/null+++ b/dashboard/src/select-chevron.test.ts@@ -0,0 +1,87 @@+import { test } from 'node:test';+import assert from 'node:assert/strict';+import { readFileSync, readdirSync } from 'node:fs';+import { fileURLToPath } from 'node:url';+import { dirname, join } from 'node:path';+import ts from 'typescript';++// index.css turns the native arrow off (appearance: none) and draws a chevron as the select's+// background-image. A later rule that sets the `background` shorthand on a select resets that image to+// none, so the select renders as an empty box with no cue that it opens a list. Rules that only mean to+// set the fill colour have to use background-color.++const SRC = dirname(fileURLToPath(import.meta.url));++function filesUnder(dir: string, ext: string): string[] {+ return readdirSync(dir, { withFileTypes: true }).flatMap(entry => {+ const full = join(dir, entry.name);+ if (entry.isDirectory()) return filesUnder(full, ext);+ return entry.name.endsWith(ext) ? [full] : [];+ });+}++// The class names carried by every <select> element in the app.+function selectClasses(): Set<string> {+ const found = new Set<string>();+ for (const full of filesUnder(SRC, '.tsx')) {+ const source = ts.createSourceFile(+ full,+ readFileSync(full, 'utf8'),+ ts.ScriptTarget.Latest,+ true,+ ts.ScriptKind.TSX,+ );+ const walk = (node: ts.Node): void => {+ if ((ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) && node.tagName.getText() === 'select') {+ for (const p of node.attributes.properties) {+ if (+ ts.isJsxAttribute(p) &&+ p.name.getText() === 'className' &&+ p.initializer &&+ ts.isStringLiteral(p.initializer)+ )+ p.initializer.text.split(/\s+/).forEach(c => found.add(c));+ }+ }+ ts.forEachChild(node, walk);+ };+ walk(source);+ }+ return found;+}++// Does the last compound selector (the element the rule styles) name `select` or a class a select carries?+function targetsSelect(selector: string, classes: Set<string>): boolean {+ const compound =+ selector+ .trim()+ .split(/[\s>+~]+/)+ .pop() ?? '';+ const head = compound.replace(/:[\w-]+(\([^)]*\))?/g, '');+ if (/^select\b/.test(head) || /(?:^|[^\w-])select(?![\w-])/.test(head)) return true;+ return [...head.matchAll(/\.([\w-]+)/g)].some(m => classes.has(m[1]));+}++test('no rule that styles a select sets the background shorthand', () => {+ const classes = selectClasses();+ assert.ok(classes.has('session-selector'), 'the sweep no longer finds the select classes');+ const offenders: string[] = [];+ for (const full of filesUnder(SRC, '.css')) {+ const css = readFileSync(full, 'utf8').replace(/\/\*[\s\S]*?\*\//g, '');+ for (const m of css.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {+ const selectors = m[1].split(',').map(s => s.trim());+ if (selectors.some(s => targetsSelect(s, classes)) && /(?:^|;)\s*background\s*:/.test(m[2]))+ offenders.push(`${full.slice(SRC.length + 1)}: ${selectors.join(', ')}`);+ }+ }+ assert.deepEqual(offenders, []);+});++test('the global select rule keeps the chevron room against a page rule that pads the select', () => {+ const css = readFileSync(join(SRC, 'index.css'), 'utf8').replace(/\/\*[\s\S]*?\*\//g, '');+ const rule = /(?:^|})\s*select\s*\{([^}]*)\}/.exec(css);+ assert.ok(rule, 'index.css has no select rule');+ assert.match(rule[1], /background-image:\s*url\(/);+ // The chevron sits in the end padding; a page rule with a padding shorthand would otherwise take it back.+ assert.match(rule[1], /padding-inline-end:\s*2\.5rem\s*!important/);+});