Skip to content

fix(x-pro): pin message-scroller preview cards to one grid cell - #238

Merged
cc-hearts merged 1 commit into
mainfrom
fix/x-pro-message-scroller-preview
Oct 9, 2026
Merged

cc-hearts merged 1 commit into
mainfrom
fix/x-pro-message-scroller-preview

Conversation

@cc-hearts

@cc-hearts cc-hearts commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

🤔 This is a ...

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

🔗 Related Issues

Fixes a defect in MessageScroller shipped by #228. Reported while reviewing the Pro docs page.

💡 Background and Solution

Background

Hovering adjacent ticks on the message navigation rail made the floating preview card jolt vertically on every switch.

Vue's <Transition> keeps both the outgoing and incoming child in the DOM for the duration of the cross-fade — only out-in / in-out remove one early. The track is a display: grid with no explicit cell, so grid-auto-flow: row auto-placed the two coexisting cards onto two rows:

  • the track's height doubled for the length of the swap (~2× card height);
  • the preview layer is display: flex; align-items: center, so it re-centred the taller track and pushed the card up by roughly half a card height, then dropped it back once the leaving node was removed.

Repeated on every hover switch, that reads as violent jitter.

Solution

  • Pin both cards to the same grid cell (gridArea: "1 / 1" on .ant-message-scroller-preview). The track then stays at the taller card's height instead of the sum, and the centred layer no longer moves.
  • The singleton card keeps sliding between ticks via the track's translateY; only the layout that produced the bounce changed.
  • Deliberately did not use mode="wait": it would serialize the swap, blink the card out mid-slide, and queue under fast pointer sweeps — worse, not smoother.

Verification

  • New regression assertion in theme.test.ts pins the invariant at the stylesheet level (VTU stubs Transition, so the DOM never shows both cards). Confirmed non-vacuous: it fails without gridArea and passes with it.
  • vp test --run packages/x-pro → 64 passed. vp check → 0 errors.

📝 Change Log

Language Changelog
🇺🇸 English MessageScroller: the rail preview card no longer jolts vertically when hovering between ticks.
🇨🇳 Chinese MessageScroller:悬停在导轨刻度之间时,预览卡片不再上下抖动。

`Transition` keeps the outgoing and incoming preview cards in the DOM at the
same time while they cross-fade. The track is a grid with no explicit cell, so
auto-placement put the two nodes on separate rows: the track's height doubled
for the duration of the swap, pushing the vertically centred preview layer up
and then dropping it back — a visible jolt on every switch.

Pinning both cards to `1 / 1` keeps the track at the taller card's height, so
the layer stays put.
@pkg-pr-new

pkg-pr-new Bot commented Oct 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/antdv-next/x/@antdv-next/x@238
npm i https://pkg.pr.new/antdv-next/x/@antdv-next/x-markdown@238
npm i https://pkg.pr.new/antdv-next/x/@antdv-next/x-sdk@238

commit: 3303a3d

@codecov

codecov Bot commented Oct 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cc-hearts
cc-hearts merged commit 76c4a88 into main Oct 9, 2026
11 checks passed
@cc-hearts
cc-hearts deleted the fix/x-pro-message-scroller-preview branch October 9, 2026 07:28
cc-hearts added a commit that referenced this pull request Oct 19, 2026
#259)

`Transition` 默认模式在切换期间同时保留新旧两张预览卡片,二者钉在轨道同一个
网格单元里交叉淡入淡出:半透明的新卡片透出旧文案,切换瞬间浮层出现重影。

逐帧实测参考实现 beUI MessageScroller 的 rail:全程只有一张卡片,文案在一帧内
直接落到新激活项,卡片位置由轨道连续滑行——没有叠字。这里对齐该行为:去掉预览
卡片的 `Transition`,内容即换即走,`translateY` 滑行保留。

随之删除只为「两张卡不叠行」服务的 `grid-area: 1 / 1` 钉格(#238 引入,交叉淡入
淡出消失后该约束已无对象)、`preview-motion` 的 enter/leave 样式、reduced-motion
对应项,以及 pin 该钉格的主题测试。
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