Skip to content

feat(client): 列内滚动时,把项目分组头钉在列的顶部 - #47

Merged
cloader merged 1 commit into
cloader:mainfrom
MoruTeaven:feat/sticky-project-headers
Oct 14, 2026
Merged

cloader merged 1 commit into
cloader:mainfrom
MoruTeaven:feat/sticky-project-headers

Conversation

@MoruTeaven

@MoruTeaven MoruTeaven commented Oct 13, 2026 •

Copy link
Copy Markdown

概述

列内滚动时,把项目分组头钉在列的顶部。

看板每一列的列头(待办 / 进行中 / 待验收 + 数量)位于滚动容器之外,本身不会滚走;但列内的项目分组头(📁 项目名)会跟着卡片一起滚上去。列一长,正在看的项目名就先离开屏幕,剩下的卡片看不出属于哪个项目。

本次改动让分组头在列内滚动时吸顶;下一组到达顶部时把它顶走(sticky 的标准表现),因此不会出现「头显示 A 组、下面是 B 组卡片」的误导。

实测数据

用 Edge 驱动真实 DOM 测量第一列各分组头相对滚动容器顶部的偏移(单位 px,@2 = 贴在容器顶部,负值 = 已滚出):

改动

src/client/styles.ts(.dsh-atb-ws-group-head,14 行):

  • position: sticky; top: 0; z-index: 2
  • 底色改为不透明:三层叠加(--dsw-alias-bg-base 打底 + 列的 inset + hover 染色)精确复现该行背后的实际颜色,卡片从下方滑过时不会透出文字。原来的 rgba(128,128,128,.08) 半透明色在吸顶后会透字。

tests/sticky-group-head.spec.ts(新增):断言两件容易静默回归的事——

  1. 结构前提:sticky 元素的祖先链必须真的包含滚动容器 .dsh-atb-cards。若分组头被移到容器外,或中间插入带 overflow: hidden / transform 的祖先,sticky 会静默失效退化成普通行,而仅断言样式文本的测试抓不到这一点。
  2. 样式规则本身:position: sticky / top: 0 存在,且底色带不透明基色。

lib/client.js:仓库约定提交预构建产物(GitHub 源安装免构建),已 npm run build 重建。

验证

  • npx tsc --noEmit 通过
  • npx vitest run 全量 408 个测试通过(30 个文件)
  • 新增测试做过反向验证:临时把 position: sticky 改回 static,测试如期失败;恢复后通过
  • 明暗两套主题下截图确认视觉正常

备注

未改动 changelog:当前 0.8.8 为已发布版本,按仓库惯例发版文案由维护者统一整理。若需要我在某个 dev 条目下补一条,告诉我即可。


Summary (English)

Pins the project group header (📁 <project>) to the top of each column's card scroller.

The column head itself (待办 / 进行中 / 待验收 + count) never scrolls — it sits outside the scroller. What did scroll away was the project row, so on a long column the project label left the screen first and the remaining cards lost their grouping context.

The header now sticks; the next group pushes it out (standard sticky behaviour), so it never mislabels the cards beneath it.

Change — src/client/styles.ts: position: sticky; top: 0; z-index: 2 plus an opaque fill. Three stacked layers (board base + column inset + hover tint) reproduce exactly what sits behind the row, so cards sliding underneath never bleed through; the previous semi-transparent rgba(128,128,128,.08) would show text through once pinned.

Test — tests/sticky-group-head.spec.ts asserts (1) the sticky element's ancestor chain actually contains the scroll container (a header moved outside it, or an overflow: hidden / transform ancestor in between, silently degrades sticky to a normal row — a stylesheet-text-only assertion would miss it) and (2) the rule carries sticky + an opaque base. Verified the test fails when sticky is reverted to static.

Verified — tsc --noEmit clean; full suite 408 passed / 30 files; measured before/after offsets in a real browser (table above); screenshots checked in both themes. No changelog edit (0.8.8 is already released; the repo's convention is for the maintainer to write release notes).

@MoruTeaven MoruTeaven changed the title feat(client): pin project group headers while a column scrolls feat(client): 列内滚动时,把项目分组头钉在列的顶部 Oct 13, 2026
@cloader
cloader merged commit 93e7d6d into cloader:main Oct 14, 2026
cloader added a commit that referenced this pull request Oct 14, 2026
Add the bilingual 0.8.9 changelog section for the merged PR #47 (sticky project group headers with an opaque three-layer fill, credited to @MoruTeaven) and sync the board feature bullet plus the in-README upgrade logs in both locales.
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.

2 participants