Skip to content

fix(web/style): 鼠标 hover post-list 时滚动条占位导致内容左右抖动#109

Merged
github-actions[bot] merged 1 commit into
mainfrom
judy/fix-scrollbar-gutter
Jun 26, 2026
Merged

fix(web/style): 鼠标 hover post-list 时滚动条占位导致内容左右抖动#109
github-actions[bot] merged 1 commit into
mainfrom
judy/fix-scrollbar-gutter

Conversation

@SymbolStar

Copy link
Copy Markdown
Owner

问题

鼠标移进 thread message 页面时右侧滚动条出现占位,鼠标移走占位消失,肉眼可见内容左右抖动。

根因

PR #93(7a804fd「scrollbar on hover」)把 #post-list 的 scrollbar 改成 hover 时显示,靠 hover 切换 scrollbar-width: none → auto 实现。这个切换在 Firefox 和 Chromium 都会真正占走 ~10px 布局宽度

  • 鼠标进入 post-list → scrollbar-width 从 none 变 auto → bar 占走 10px → 内容左移
  • 鼠标离开 → 反向 → 内容右移回来

修复

#post-list {
  scrollbar-gutter: stable;
}

永远预留 gutter,bar 仍然只在 hover 时画。视觉上跟之前完全一致(默认空、hover 出现),但布局宽度恒定,鼠标进出零 reflow。

关联

原本是想跟 PR #106(keyed-diff renderPosts)一起修,但 #106 已经在 scrollbar 那个 commit push 上去之前 merge 了,所以单独开一个 PR。

验证

  • Firefox / Chromium:hover 进出 post-list,内容不再抖动。
  • 默认外观(无 hover)不变。
  • 滚动条 hover 时仍然出现(Slack-style 不变)。

PR #93 把 #post-list 的 scrollbar 改成 hover 时显示,通过 hover 切换
scrollbar-width: none → auto 实现。但这个切换在 Firefox 和 Chromium
都会真正占走 ~10px 布局宽度,鼠标移进 post-list 内容左移 10px、移走
再右移回来,肉眼可见的抖动。

修法:scrollbar-gutter: stable 永远预留 gutter,bar 仍然只在 hover
时画。视觉上跟之前完全一致(默认空、hover 出现),但布局宽度恒定,
鼠标进出零 reflow。

(原本是跟 PR #106 keyed-diff 一起修的,但 #106 在 scrollbar 改动 push
上去之前就 merge 了,所以这里单独再开一个 PR。)
@github-actions

Copy link
Copy Markdown

🤖 bot-review (comment-only · phase 1)

Diff: 2 files changed, 7 insertions(+) @ 870449f

Red-line checks:

  • ✅ A-7.5: no new 'forbidden' code in xiaof

Phase 2: auto-approve + auto-merge fire only when red-lines are clean, author is internal, and no needs-human path is touched. Block with no-auto-merge label or [no-auto-merge] in title.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Auto-approved by bot-review: red-line checks clean, internal author, no needs-human paths.

@github-actions github-actions Bot enabled auto-merge (squash) June 26, 2026 09:15
@github-actions github-actions Bot merged commit f5f51c6 into main Jun 26, 2026
7 checks passed
github-actions Bot pushed a commit that referenced this pull request Jun 29, 2026
PR #109 用 scrollbar-gutter: stable 想保留 gutter,但 CSS 规范规定
gutter 在 scrollbar-width: none 时是 no-op,所以那行修改实际上根本
没生效,hover 切到 auto 仍然会真占走 ~10px。Scott 反馈刷新后还在抖
就是这个原因。

正确做法:让 scrollbar 始终挂载且宽度固定,默认 thumb / track 全透明,
hover 时把 thumb 上色。视觉上跟之前的 Slack-style hover-reveal 完全一样
(默认看不到、hover 出现),但布局宽度恒定,鼠标进出零 reflow。

- WebKit/Chromium/Safari:::-webkit-scrollbar 固定 width: 10px,
  ::-webkit-scrollbar-thumb 默认 transparent,hover 时上色。
- Firefox:scrollbar-width: thin + scrollbar-color: transparent
  transparent 默认,hover 时把 thumb 颜色切到 rgba(0,0,0,0.25)。
- 加 0.15s transition 让出现/消失更柔和。

SW 已经在 v2 = network-first,下次硬刷新一次直接生效。

Co-authored-by: judy <judy@symbolstar.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant