Skip to content

Commit c1a30c0

Browse files
committed
refactor(steps): fix content-placement PR
1 parent 16e6ecc commit c1a30c0

File tree

4 files changed

+31
-20
lines changed

4 files changed

+31
-20
lines changed

src/steps/demos/enUS/index.demo-entry.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ click.vue
2222

2323
| Name | Type | Default | Description | Version |
2424
| --- | --- | --- | --- | --- |
25+
| content-placement | `'right' \| 'bottom'` | `right` | Steps content placement, only can be used in horizontal mode. | NEXT_VERSION |
2526
| current | `number` | `undefined` | Currently active step index. | |
2627
| size | `'small' \| 'medium'` | `'medium'` | Steps size. | |
2728
| status | `'process' \| 'finish' \| 'error' \| 'wait'` | `'process'` | Steps status. | |
2829
| vertical | `boolean` | `false` | Steps vertical. | |
29-
| content-placement | `'right' \| 'bottom'` | `right` | Steps content placement, only can be used in horizontal mode. | NEXT_VERSION |
3030
| on-update:current | `(index: number) => void` | `undefined` | Callback on currently active step index changed. If it's set, step can be switched by click. | 2.29.1 |
3131

3232
### Step Props

src/steps/demos/zhCN/index.demo-entry.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ rtl-debug.vue
2424

2525
| 名称 | 类型 | 默认值 | 说明 | 版本 |
2626
| --- | --- | --- | --- | --- |
27+
| content-placement | `'right' \| 'bottom'` | `right` | 步骤条内容位置,仅在横向模式下生效 | NEXT_VERSION |
2728
| current | `number` | `undefined` | 当前选中在第几步 | |
2829
| size | `'small' \| 'medium'` | `'medium'` | 步骤条大小 | |
2930
| status | `'process' \| 'finish' \| 'error' \| 'wait'` | `'process'` | 步骤条状态 | |
3031
| vertical | `boolean` | `false` | 步骤条方向 | |
31-
| content-placement | `'right' \| 'bottom'` | `right` | 步骤条内容位置,仅在横向模式下生效 | NEXT_VERSION |
3232
| on-update:current | `(index: number) => void` | `undefined` | 更新当前第几步的回调,设定后可点击切换步骤 | 2.29.1 |
3333

3434
### Step Props

src/steps/src/Step.tsx

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,14 @@ export default defineComponent({
159159
}
160160
},
161161
render() {
162-
const { mergedClsPrefix, onRender, handleStepClick, disabled } = this
162+
const {
163+
mergedClsPrefix,
164+
onRender,
165+
handleStepClick,
166+
disabled,
167+
contentPlacement,
168+
vertical
169+
} = this
163170
const descriptionNode = resolveWrappedSlot(
164171
this.$slots.default,
165172
(children) => {
@@ -177,7 +184,10 @@ export default defineComponent({
177184
const splitorNode = <div class={`${mergedClsPrefix}-step-splitor`} />
178185

179186
const indicatorNode = (
180-
<div class={`${mergedClsPrefix}-step-indicator`}>
187+
// We need a key here to make reconcile progress doesn't affect styling.
188+
// A DOM can be reused so if it is used both for A component & B component,
189+
// the styling transition bewteen two components may be incorrect.
190+
<div class={`${mergedClsPrefix}-step-indicator`} key={contentPlacement}>
181191
<div class={`${mergedClsPrefix}-step-indicator-slot`}>
182192
<NIconSwitchTransition>
183193
{{
@@ -219,7 +229,7 @@ export default defineComponent({
219229
}}
220230
</NIconSwitchTransition>
221231
</div>
222-
{this.vertical ? splitorNode : null}
232+
{vertical ? splitorNode : null}
223233
</div>
224234
)
225235
const contentNode = (
@@ -228,31 +238,32 @@ export default defineComponent({
228238
<div class={`${mergedClsPrefix}-step-content-header__title`}>
229239
{resolveSlot(this.$slots.title, () => [this.title])}
230240
</div>
231-
{!this.vertical && this.contentPlacement === 'right'
232-
? splitorNode
233-
: null}
241+
{!vertical && contentPlacement === 'right' ? splitorNode : null}
234242
</div>
235243
{descriptionNode}
236244
</div>
237245
)
238246

239-
let stepNode = (
240-
<Fragment>
241-
{indicatorNode}
242-
{contentNode}
243-
</Fragment>
244-
)
245-
if (!this.vertical && this.contentPlacement === 'bottom') {
247+
let stepNode: VNode
248+
if (!vertical && contentPlacement === 'bottom') {
246249
stepNode = (
247250
<Fragment>
248-
<div class={`${mergedClsPrefix}-step-content-bottom-header`}>
251+
<div class={`${mergedClsPrefix}-step-line`}>
249252
{indicatorNode}
250253
{splitorNode}
251254
</div>
252255
{contentNode}
253256
</Fragment>
254257
)
255258
}
259+
else {
260+
stepNode = (
261+
<Fragment>
262+
{indicatorNode}
263+
{contentNode}
264+
</Fragment>
265+
)
266+
}
256267
onRender?.()
257268
return (
258269
<div

src/steps/src/styles/index.cssr.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ export default cB('steps', `
154154
c('>', [
155155
cB('step', 'flex-direction: column', [
156156
c('>', [
157-
cB('step-content-bottom-header', 'display: flex;', [
157+
cB('step-line', 'display: flex;', [
158158
c('>', [
159159
cB('step-splitor', `
160-
margin-top: 0;
161-
align-self: center;
162-
`)
160+
margin-top: 0;
161+
align-self: center;
162+
`)
163163
]),
164164
])
165165
]),

0 commit comments

Comments
 (0)