Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🧵 fix: Restore Classes tailwind-merge Was Silently Dropping (#15995)

Marco Beretta5b0ff1491d14
diff --git a/bun.lock b/bun.lock
index 007639c297..8eb42917e3 100644
--- a/bun.lock
+++ b/bun.lock
@@ -245,7 +245,7 @@
"remark-supersub": "^1.0.0",
"sse.js": "^2.8.0",
"swr": "^2.3.8",
- "tailwind-merge": "^1.9.1",
+ "tailwind-merge": "^2.6.1",
"tailwindcss-animate": "^1.0.5",
"tailwindcss-radix": "^2.8.0",
"ts-md5": "^1.3.1",
@@ -485,7 +485,7 @@
"react-i18next": "^15.4.0 || ^15.6.0",
"react-resizable-panels": "^4.7.4",
"react-textarea-autosize": "^8.4.0",
- "tailwind-merge": "^1.9.1",
+ "tailwind-merge": "^2.6.1",
},
},
"packages/data-provider": {
@@ -4765,7 +4765,7 @@
"tabbable": ["[email protected]", "", {}, "sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew=="],
- "tailwind-merge": ["[email protected]", "", {}, "sha512-3mFKyCo/MBcgyOTlrY8T7odzZFx+w+qKSMAmdFzRvqBfLlSigU6TZnlFHK0lkMwj9Bj8OYU+9yW9lmGuS0QEnQ=="],
+ "tailwind-merge": ["[email protected]", "", {}, "sha512-Oo6tHdpZsGpkKG88HJ8RR1rg/RdnEkQEfMoEk2x1XRI3F1AxeU+ijRXpiVUF4UbLfcxxRGw6TbUINKYdWVsQTQ=="],
"tailwindcss": ["[email protected]", "", { "dependencies": { "@alloc/quick-lru": "^5.2.0", "arg": "^5.0.2", "chokidar": "^3.5.3", "didyoumean": "^1.2.2", "dlv": "^1.1.3", "fast-glob": "^3.3.0", "glob-parent": "^6.0.2", "is-glob": "^4.0.3", "jiti": "^1.19.1", "lilconfig": "^2.1.0", "micromatch": "^4.0.5", "normalize-path": "^3.0.0", "object-hash": "^3.0.0", "picocolors": "^1.0.0", "postcss": "^8.4.23", "postcss-import": "^15.1.0", "postcss-js": "^4.0.1", "postcss-load-config": "^4.0.1", "postcss-nested": "^6.0.1", "postcss-selector-parser": "^6.0.11", "resolve": "^1.22.2", "sucrase": "^3.32.0" }, "bin": { "tailwind": "lib/cli.js", "tailwindcss": "lib/cli.js" } }, "sha512-qAYmXRfk3ENzuPBakNK0SRrUDipP8NQnEY6772uDhflcQz5EhRdD7JNZxyrFHVQNCwULPBn6FNPp9brpO7ctcA=="],
diff --git a/client/package.json b/client/package.json
index 7db80507c8..9f12531c29 100644
--- a/client/package.json
+++ b/client/package.json
@@ -126,7 +126,7 @@
"remark-supersub": "^1.0.0",
"sse.js": "^2.8.0",
"swr": "^2.3.8",
- "tailwind-merge": "^1.9.1",
+ "tailwind-merge": "^2.6.1",
"tailwindcss-animate": "^1.0.5",
"tailwindcss-radix": "^2.8.0",
"ts-md5": "^1.3.1",
diff --git a/client/src/utils/artifacts.ts b/client/src/utils/artifacts.ts
index e192e93061..8c02ee4b74 100644
--- a/client/src/utils/artifacts.ts
+++ b/client/src/utils/artifacts.ts
@@ -244,7 +244,7 @@ const standardDependencies = {
'class-variance-authority': '^0.6.0',
clsx: '^1.2.1',
'date-fns': '^3.3.1',
- 'tailwind-merge': '^1.9.1',
+ 'tailwind-merge': '^2.6.1',
'tailwindcss-animate': '^1.0.5',
recharts: '2.12.7',
'@radix-ui/react-accordion': '^1.1.2',
@@ -283,7 +283,7 @@ const mermaidDependencies = {
'react-zoom-pan-pinch': '^3.6.1',
'class-variance-authority': '^0.6.0',
clsx: '^1.2.1',
- 'tailwind-merge': '^1.9.1',
+ 'tailwind-merge': '^2.6.1',
'@radix-ui/react-slot': '^1.1.0',
};
diff --git a/e2e/specs/mock/scenarios/dropped-classes.spec.ts b/e2e/specs/mock/scenarios/dropped-classes.spec.ts
new file mode 100644
index 0000000000..dfc2a89d1e
--- /dev/null
+++ b/e2e/specs/mock/scenarios/dropped-classes.spec.ts
@@ -0,0 +1,66 @@
+import { expect, test } from '@playwright/test';
+import { computedStyles } from './style.helpers';
+
+/**
+ * `cn()` is `twMerge(clsx(...))`, so it deletes any class it believes conflicts
+ * with a later one — and `[email protected]` predates Tailwind 3.3, so its
+ * conflict map is wrong in two ways that reach this app. It has one group for
+ * every `touch-*` utility, which are combinable, so the earlier one is dropped.
+ * And it has no group for `size-*` at all, so both survive and the stylesheet
+ * order decides, which is never what the caller asked for.
+ *
+ * Both scenarios below name a surface whose classes really pass through `cn()`
+ * and ask the browser what the element got. Under 1.9.1 each reports the other
+ * value; the merged `class` attribute is included because it is the merge's own
+ * output, and the computed style is what a user sees of it.
+ */
+
+test.describe('classes that survive cn()', () => {
+ test.describe('the mobile drawer', () => {
+ /** Below `sm` the sidebar is a drawer; the mock config has one desktop
+ * project, so the spec declares the viewport it describes. */
+ test.use({ viewport: { width: 390, height: 844 } });
+
+ test('the mobile drawer keeps vertical panning @scenario:the-mobile-drawer-keeps-vertical-panning', async ({
+ page,
+ }) => {
+ await page.goto('/c/new', { timeout: 30000 });
+
+ const drawer = page.locator('#mobile-drawer');
+ await expect(drawer).toBeAttached({ timeout: 30000 });
+
+ /** `touch-pan-y touch-pinch-zoom` is the pair the drawer writes: the close
+ * swipe reads horizontal touches, and zoom stays with the browser. v1
+ * groups every `touch-*` utility together and keeps only the last, so the
+ * drawer lost vertical panning — a surface that no longer scrolls. */
+ const { touchAction } = await computedStyles(drawer, ['touchAction']);
+ expect(touchAction).toContain('pan-y');
+ expect(touchAction).toContain('pinch-zoom');
+ await expect(drawer).toHaveClass(/touch-pan-y/);
+ });
+ });
+
+ test('a header icon button keeps the size its caller set @scenario:a-header-icon-button-keeps-the-size-its-caller-set', async ({
+ page,
+ }) => {
+ test.setTimeout(120_000);
+ await page.goto('/c/new', { timeout: 30000 });
+
+ /** The header's overflow trigger is a `Button size="icon"`, whose recipe
+ * contributes `size-10`, with `size-9` written by the call site. `cn()` has
+ * to keep the caller's: 1.9.1 knows no `size-*` group, so it keeps both,
+ * and `.size-10` is emitted after `.size-9` — the button silently renders
+ * at 40px instead of the 36px the header lays out for. It is `md:hidden`,
+ * so the assertion reads the computed box, which is defined whether or not
+ * the viewport shows it. */
+ const trigger = page.getByTestId('header-overflow-menu');
+ await expect(trigger).toBeAttached({ timeout: 30000 });
+
+ await expect(trigger).toHaveClass(/\bsize-9\b/);
+ await expect(trigger).not.toHaveClass(/\bsize-10\b/);
+
+ const { width, height } = await computedStyles(trigger, ['width', 'height']);
+ expect(width).toBe('36px');
+ expect(height).toBe('36px');
+ });
+});
diff --git a/e2e/specs/mock/scenarios/style.helpers.ts b/e2e/specs/mock/scenarios/style.helpers.ts
new file mode 100644
index 0000000000..5476c69262
--- /dev/null
+++ b/e2e/specs/mock/scenarios/style.helpers.ts
@@ -0,0 +1,30 @@
+import type { Locator } from '@playwright/test';
+
+/**
+ * Style probes for the scenarios that assert what the app paints. Both sides of
+ * every comparison are resolved by the browser out of the stylesheet the app
+ * shipped, never written down here: the same assertion then holds in light mode,
+ * dark mode, under a custom theme, and across a Tailwind major.
+ */
+
+/**
+ * Read several computed properties off a rendered element in one round trip.
+ * Names are written the way the callers read them back (`touchAction`);
+ * `getPropertyValue` only answers to the CSS spelling, so the hyphenation
+ * happens here rather than at each call site — and a name it does not know
+ * comes back empty, which fails the assertion instead of passing it.
+ */
+export function computedStyles<K extends string>(
+ locator: Locator,
+ properties: readonly K[],
+): Promise<Record<K, string>> {
+ return locator.evaluate((node, names: readonly string[]) => {
+ const style = getComputedStyle(node as HTMLElement);
+ const result: Record<string, string> = {};
+ for (const name of names) {
+ const property = name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
+ result[name] = style.getPropertyValue(property).trim();
+ }
+ return result;
+ }, properties) as Promise<Record<K, string>>;
+}
diff --git a/package-lock.json b/package-lock.json
index 0bbd79b771..55e8000bb5 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -956,7 +956,7 @@
"remark-supersub": "^1.0.0",
"sse.js": "^2.8.0",
"swr": "^2.3.8",
- "tailwind-merge": "^1.9.1",
+ "tailwind-merge": "^2.6.1",
"tailwindcss-animate": "^1.0.5",
"tailwindcss-radix": "^2.8.0",
"ts-md5": "^1.3.1",
@@ -39632,9 +39632,10 @@
"license": "MIT"
},
"node_modules/tailwind-merge": {
- "version": "1.14.0",
- "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-1.14.0.tgz",
- "integrity": "sha512-3mFKyCo/MBcgyOTlrY8T7odzZFx+w+qKSMAmdFzRvqBfLlSigU6TZnlFHK0lkMwj9Bj8OYU+9yW9lmGuS0QEnQ==",
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-2.6.1.tgz",
+ "integrity": "sha512-Oo6tHdpZsGpkKG88HJ8RR1rg/RdnEkQEfMoEk2x1XRI3F1AxeU+ijRXpiVUF4UbLfcxxRGw6TbUINKYdWVsQTQ==",
+ "license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/dcastil"
@@ -43407,7 +43408,7 @@
"react-i18next": "^15.4.0 || ^15.6.0",
"react-resizable-panels": "^4.7.4",
"react-textarea-autosize": "^8.4.0",
- "tailwind-merge": "^1.9.1"
+ "tailwind-merge": "^2.6.1"
}
},
"packages/client/node_modules/@adobe/css-tools": {
diff --git a/packages/client/package.json b/packages/client/package.json
index 4142ade428..abfe0a420b 100644
--- a/packages/client/package.json
+++ b/packages/client/package.json
@@ -89,7 +89,7 @@
"react-i18next": "^15.4.0 || ^15.6.0",
"react-resizable-panels": "^4.7.4",
"react-textarea-autosize": "^8.4.0",
- "tailwind-merge": "^1.9.1"
+ "tailwind-merge": "^2.6.1"
},
"devDependencies": {
"@babel/core": "^7.28.5",