From 04f45e0b29aae3051829d92035c1cb0e1fa4efae Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Wed, 28 Oct 2026 03:36:44 +0100 Subject: [PATCH] fix: point the plugin sidebar section arrows the right way in right-to-left languages --- .../layout/__tests__/rtl-icon-flips.test.ts | 42 +++++++++++++++++++ .../plugins/plugin-sidebar-sections.tsx | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 components/layout/__tests__/rtl-icon-flips.test.ts diff --git a/components/layout/__tests__/rtl-icon-flips.test.ts b/components/layout/__tests__/rtl-icon-flips.test.ts new file mode 100644 index 000000000..b9edb4a77 --- /dev/null +++ b/components/layout/__tests__/rtl-icon-flips.test.ts @@ -0,0 +1,42 @@ +import { readdirSync, readFileSync, statSync } from 'node:fs'; +import { join } from 'node:path'; +import { describe, expect, it } from 'vitest'; + +// globals.css already mirrors chevron and arrow icons under [dir=rtl]. An +// extra rtl:rotate-180 or rtl:-scale-x-100 on top cancels that out, and the +// icon points the left-to-right way again (R11). Checked in the shell's own +// folders. + +const ROOTS = [ + 'components/layout', + 'components/plugins', + 'components/tour', + 'components/notifications', + 'components/command-palette', + 'components/global-search', + 'components/auth', + 'components/error', + 'app/(main)/[locale]/login', +]; + +function sources(dir: string): string[] { + return readdirSync(dir).flatMap((name) => { + const path = join(dir, name); + if (name === '__tests__' || name === 'node_modules') return []; + if (statSync(path).isDirectory()) return sources(path); + return /\.tsx?$/.test(name) ? [path] : []; + }); +} + +describe('directional icons in right-to-left languages', () => { + it('rely on the global mirror only', () => { + const offenders = ROOTS.flatMap(sources).flatMap((file) => + readFileSync(file, 'utf8') + .split('\n') + .map((line, i) => ({ line, at: `${file}:${i + 1}` })) + .filter(({ line }) => /<(Chevron|Arrow)\w*[^>]*\brtl:(rotate-180|-scale-x-100)/.test(line)) + .map(({ at }) => at), + ); + expect(offenders).toEqual([]); + }); +}); diff --git a/components/plugins/plugin-sidebar-sections.tsx b/components/plugins/plugin-sidebar-sections.tsx index bb77c2287..65f287da6 100644 --- a/components/plugins/plugin-sidebar-sections.tsx +++ b/components/plugins/plugin-sidebar-sections.tsx @@ -52,7 +52,7 @@ function PluginSidebarSection({ pluginId, extraProps }: { pluginId: string; extr className="group flex flex-1 min-w-0 items-center select-none rounded-sm hover:bg-muted/40 transition-colors" > {collapsed ? ( - + ) : ( )}