-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix(web-shell): keep the auto-sized dialog's gutter on a phone #11077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -187,7 +187,13 @@ describe('DialogShell', () => { | |||||||||||||||||||||||
| // stays full-width and never tracks the content. | ||||||||||||||||||||||||
| expect(panel.className).toContain('w-max'); | ||||||||||||||||||||||||
| expect(panel.className).not.toContain('w-full'); | ||||||||||||||||||||||||
| expect(panel.className).toContain('min-w-[min(100%,560px)]'); | ||||||||||||||||||||||||
| // The floor has to subtract the same gutter the surviving base ceiling | ||||||||||||||||||||||||
| // (`max-w-[calc(100%-2rem)]`) reserves. twMerge keeps both classes, and | ||||||||||||||||||||||||
| // below `sm:` a bare `min(100%,560px)` floor outranks that ceiling, so the | ||||||||||||||||||||||||
| // panel would render flush to both screen edges on a phone. | ||||||||||||||||||||||||
| expect(panel.className).toContain('min-w-[min(calc(100%-2rem),560px)]'); | ||||||||||||||||||||||||
| expect(panel.className).not.toContain('min-w-[min(100%,560px)]'); | ||||||||||||||||||||||||
| expect(panel.className).toContain('max-w-[calc(100%-2rem)]'); | ||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] The cross-file invariant this fix rests on — the Witness:
Suggested change
One fact the fix must not violate: neither class name may be composed from a shared constant or interpolation. Both sites ship complete literals that Tailwind extracts by scanning source text — Acceptance criterion: the same Worth saying plainly: this one is a judgment call a maintainer may decline. The wrong path is not silent — it requires greening a red test by editing a literal whose four-line comment directly above spells out the floor/ceiling relationship — and AGENTS.md's Simplicity First rule is a defensible reason not to add a regex self-consistency assertion over Tailwind arbitrary-value strings. 中文说明这个修复所依赖的跨文件不变量 —— (witness 与 修复不能违反的一个既有事实:两个类名都不能由共享常量或字符串插值拼出来。两处都是以完整字面量发布的,Tailwind 靠扫描源码文本提取它们 —— 验收标准:去掉这个防护时应当变红的,就是同一个 坦白说一句:这一条属于维护者完全可以不接受的取舍。走错的那条路并非无声无息 —— 它要求开发者通过修改一个字面量来把红灯变绿,而那个字面量正上方就有四行注释把下限/上限的关系讲清楚了 —— 而且按 AGENTS.md 的 Simplicity First 原则,不为 Tailwind 任意值字符串增加一条正则自洽断言,也是一个站得住脚的选择。 — qwen3.8-max via Qwen Code /review (v0.23.0) |
||||||||||||||||||||||||
| expect(panel.className).toContain( | ||||||||||||||||||||||||
| 'sm:max-w-[min(calc(100vw-2rem),1120px)]', | ||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion] This literal is a complete Tailwind candidate sitting in a file Tailwind scans, so the flush-to-edges floor this PR sets out to retire is still compiled into the published CSS even though no component uses it any more. There is no
@sourcedirective anywhere inclient/styles/and this file is not git-ignored, so Tailwind v4's automatic source detection lifts the candidate straight out of the assertion and emits a rule for it.README.md:51states the compiled Tailwind output is inlined into the published npm package, so the retired expression ships in every consumer's injected CSS permanently, and a grep of the built artifact for the flush-to-edges floor still returns a live-looking scoped rule. A future author who copiesmin-w-[min(100%,560px)]from this test or from the built CSS reintroduces exactly the bug this PR fixes, and this assertion stays green because it only inspects one auto dialog's className.It also buys no guard: it reddens on the same source revert that line 194 already catches, and the both-literals-present state it looks like it uniquely covers is unreachable through
cn().Witness:
One fact the fix must not violate: line 194,
expect(panel.className).toContain('min-w-[min(calc(100%-2rem),560px)]');, has to stay — removing line 195 leaves it as the only pin on the floor, and the probe confirms it still reddens on a source revert.Acceptance criterion:
client/build-artifact.test.tsalready parses the inlined__qwenWebShellCssout ofdist/index.jswith postcss (readInjectedCss(), used by the existingscopes every component CSS rule to a WebShell rootcase), so an added case asserting no rule there declaresmin-width:min(100%,560px)is the guard that should replace this one — please confirm it goes red against today's artifact, and red again if line 195 is restored after the fix.中文说明
这个字面量本身就是一个完整的 Tailwind 候选类,而它所在的文件会被 Tailwind 扫描,因此本 PR 想要退役的「贴边」宽度下限,仍然会被编译进发布的 CSS —— 尽管已经没有任何组件在用它。
client/styles/里没有任何@source指令,这个文件也没有被 git-ignore,所以 Tailwind v4 的自动源探测会直接从这条断言里把候选类取走并为它生成规则。README.md:51说明编译后的 Tailwind 产物会被内联进发布的 npm 包,于是这个已退役的表达式会永久地随每个使用方注入的 CSS 一起发布;在构建产物里 grep 这个贴边下限,仍然会返回一条看起来生效的、带作用域的规则。将来若有人从这个测试文件或构建产物里照抄min-w-[min(100%,560px)],就会把本 PR 修掉的 bug 原样带回来 —— 而这条断言依然是绿的,因为它只检查一个 auto 对话框的 className。它也没有换来任何防护:源码回退时它会变红,但同一次回退第 194 行本来就能拦住;而它看起来独有的那个「两个字面量同时出现」状态,经过
cn()根本不可达。( witness 与
suggestion块见上方英文部分。)修复不能违反的一个既有事实:第 194 行
expect(panel.className).toContain('min-w-[min(calc(100%-2rem),560px)]');必须保留 —— 删掉第 195 行之后,它是下限唯一的钉住点,探针已确认源码回退时它仍会变红。验收标准:
client/build-artifact.test.ts已经用 postcss 从dist/index.js解析出内联的__qwenWebShellCss(readInjectedCss(),现有的scopes every component CSS rule to a WebShell root用例就在用它),所以应当由一条新用例来替代这个防护 —— 断言其中没有任何规则声明min-width:min(100%,560px)。请确认它在当前产物上是红的,并且在修复之后若把第 195 行加回去,它会再次变红。— qwen3.8-max via Qwen Code /review (v0.23.0)