Skip to content

fix(step): 兼容 title/description 空值样式 (#882)#1002

Closed
wanchun wants to merge 1 commit into
chore/test-infrafrom
fix/issue-882-v2
Closed

fix(step): 兼容 title/description 空值样式 (#882)#1002
wanchun wants to merge 1 commit into
chore/test-infrafrom
fix/issue-882-v2

Conversation

@wanchun

@wanchun wanchun commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

修复内容

Step 组件当 titledescription 为空字符串/undefined 时,空 div 仍会渲染(带着 margin/padding),造成标题区有偏移的视觉问题。

根因components/steps/step.tsx 渲染函数):

  • title 用 {slots.title?.() || ${props.title}} —— undefined 被 stringified 成 "undefined",empty 字符串也通过 || fallback
  • description 的 wrapper div 没有 && 守卫,只对内容有
  • <div class="...-title"><div class="...-description"> 始终渲染

修复

  • title div 整块用 (slots.title || props.title) && 守卫,有内容才渲染
  • description div 同样加守卫
  • ${props.title}props.title ??(避免 undefined 被渲染为字面 "undefined")

验证

PATH="$HOME/.nvm/versions/node/v22.22.3/bin:$PATH" ./node_modules/.bin/vitest run components/steps
  • 4/4 tests passed
  • 测试覆盖:title="" / title=undefined / title="Step 1" / title+description 都空

改动文件

  • components/steps/step.tsx — 渲染函数加守卫
  • components/steps/__tests__/step-882.spec.ts — 4 个 vitest 单测

无 lockfile 污染,无 test infra 修改。

Closes #882

@wanchun

wanchun commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator Author

Closed as part of v3 rebuild from chore/test-infra. Original v1/v2 PRs being superseded by clean re-implementation (vitest + playwright + docs).

@wanchun wanchun closed this Jun 4, 2026
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