Repository navigation
🐛 修复 popup 宽度塌缩成细条、页眉页脚被挤出可视区 (#1800) - #1801
Merged
Merged
Conversation
popup.html 用 @media (min-width: 365px) 在宽视口切到 width:100% 来适配移动端(#686), 但桌面 popup 的窗口宽度由内容内在宽度反推:出现经典滚动条时视口变成 360px + 滚动条宽而命中, width:100% 让内在宽度趋近 0,Chrome 150 及以下的 autosize 算法(151 起 AutoSizeUsesScrollWidthForOverflow 才改用 scroll width)把窗口夹到最小 25px 后不再撑开。 改为 html 固定 width:360px + min-width:100%:内在宽度恒为 360px 与视口解耦, 百分比 min-width 只在移动端视口被撑满设备宽度时生效,保留 #686 的填满行为。
根容器写死 max-h-[600px](CSS px)并在内部列表滚动,但 popup 窗口上限是 600 DIP: 默认缩放 125% 时只有 480 CSS px,内容被裁出窗口后整个文档滚动,页眉滚走、页脚版本号被挤出可视区; 这条文档滚动条在经典滚动条平台上还会把视口撑宽,正是旧版 Chrome 宽度塌缩(#1800)的触发条件。 移动端整屏 popup 下内容高度不足时,页脚悬在内容下方而不是贴底。 改为文档作为唯一滚动容器:去掉固定高度上限与内部 overflow 滚动区,警告/页眉区吸顶、页脚吸底, 根容器 min-h-screen 让移动端页脚贴底;滚动条样式 scrollbar-custom 移到 html 上。 不用 vh 做上限:popup 自适应时视口高度依赖内容,实测会被夹到 150px 最小高度。 测试:新增 e2e/popup-autosize.spec.ts,用真实 action popup(chrome.action.openPopup + CDP) 在 125% 缩放 + 12 个匹配脚本下断言内容宽 360、页眉页脚在可视区、无内部滚动区且文档滚动条已主题化, 并在移动端模拟下断言宽度填满(#686)、页脚贴底。 删除 App.test.tsx 中已失效的结构断言:根容器 max-h/overflow-hidden、列表区 overflow-auto(契约已改为文档滚动), 以及上一提交改掉的 popup.html @media 文件内容断言;对应行为由上述 e2e 以真实布局覆盖。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist / 检查清单
「修复已提及的问题」未勾:触发链已在 macOS 上用 Chrome 127/150/151/153 复现并修复,但报告者的 Windows 环境未实机验证(见「已知限制」)。
Description / 描述
背景
#1800:Windows 10 + Chrome 127 下,popup 只剩一条约 25px 宽、带经典滚动条的细条。排查发现 popup 的尺寸有两处写死,都和浏览器"popup 窗口按内容自适应"的模型冲突。
popup.html用@media (min-width: 365px)在宽视口时切到width: 100%,目的是适配移动端([BUG] Edge 安卓移动端适配(脚本猫界面元素错位) #686)。但桌面 popup 出现经典滚动条时,视口宽度 = 360 + 滚动条宽,会命中这条规则。width: 100%没有内在宽度,Chrome ≤150 的自适应算法就把窗口夹到 25px,之后不再撑开。Chrome 151 引入AutoSizeUsesScrollWidthForOverflow(CL 7882031)后能撑回来,但宽度会漂到 440+px。max-h-[600px](CSS px),列表在内部滚动;而 popup 窗口上限是 600 DIP。默认缩放 125% 时窗口只有 480 CSS px,内容被裁出窗口,整个文档开始滚动:页眉滚走,页脚版本号被挤出可视区。这条文档级滚动条也就是第 1 点的触发条件——issue 截图里带箭头的经典滚动条正是它,内部列表用的是 8px 自定义滚动条。headless 下窗口上限更低,100% 缩放 + 30 个脚本也会出现。另外,移动端整屏 popup 内容不足一屏时,页脚悬在内容下方,没有贴底。本次改动
dce8bbb(宽度):去掉媒体查询,改为html { width: 360px; min-width: 100% }。桌面的内在宽度恒为 360px,与视口无关。百分比min-width只在移动端视口被撑满时生效,保留 [BUG] Edge 安卓移动端适配(脚本猫界面元素错位) #686 的效果。0b380f9(高度):文档成为唯一滚动容器。去掉固定高度上限和内部overflow-auto;警告和页眉区sticky top-0,页脚sticky bottom-0;根容器min-h-screen,让移动端页脚贴底。scrollbar-custom从列表移到<html>上。实现考虑
100vh后,127 和 153 都被夹到 150px(html的min-height):自适应时视口高度依赖内容,形成和宽度问题同样的循环。min-h-screen不会把桌面撑高。在 127 和 153 上、缩放 0.8 / 1 / 1.25 下都验证过,没有卡高;在 153 上折叠分组后 popup 仍会变矮(566 → 314)。验证
所有浏览器验证都在 headless 下进行,用真实 action popup(
chrome.action.openPopup+ CDP 测量)。"经典滚动条"指在 macOS 上用AppleShowScrollBars=Always模拟 Windows。--disable-features=AutoSizeUsesScrollWidthForOverflow后,旧版同样塌成 25px。e2e/popup-autosize.spec.ts:--repeat-each=5 --workers=2下 10/10 通过。App.test.tsx中已失效的结构断言:根容器max-h/overflow-hidden、列表overflow-auto(契约已改为文档滚动),以及popup.html@media的文件内容断言。对应行为都由上面的 e2e 以真实布局覆盖。CI 上一轮唯一失败的就是那条@media断言。pnpm run lint:通过vitest:popup 下 4 个测试文件 +viewport-meta+prerender-theme,71 passedplaywright test e2e/popup-autosize.spec.ts e2e/popup.spec.ts e2e/popup-matching-regressions.spec.ts:9 passedvitest无法作为信号:干净的 origin/main 上同样有 141 个文件失败(chrome.permissionsmock 被前序用例替换后,同 worker 后续 suite 报permissions.reset is not a function),全量以 CI 为准。已知限制
建议审查重点
src/pages/popup/App.tsx根容器:滚动容器从列表改成了文档。吸顶区和页脚的背景、层级(z-10)在明暗主题下是否遮挡下拉菜单或 Popconfirm(Radix 浮层为z-50,本地点开过「更多」菜单的 e2e 通过)。Fixes #1800