Skip to content

Commit

Permalink
Merge pull request #432 from zobor/master
Browse files Browse the repository at this point in the history
fix(Step): labelPlacement value change dbl times
  • Loading branch information
youluna authored Mar 11, 2019
2 parents 0b93378 + 3c7ae73 commit 1b00d8f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/step/view/step-item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ class StepItem extends Component {
if (shape === 'arrow') {
return;
}
const resetTailStyle = () => {
dom.setStyle(this.tail, {
width: '',
// eslint-disable-next-line
top: '',
});
};

if (direction === 'vertical' || direction === 'ver') {
this.resize();
Expand All @@ -124,13 +131,11 @@ class StepItem extends Component {
) {
// 调整横向Content
this.adjustTail();
} else {
resetTailStyle();
}
} else if (index !== total - 1) {
dom.setStyle(this.tail, {
width: '',
// eslint-disable-next-line
top: '',
});
resetTailStyle();
}
}

Expand Down
9 changes: 8 additions & 1 deletion test/step/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,22 @@ describe('Step', () => {

assert(wrapper.find('.next-step-label-vertical').length === 1);
wrapper.setProps({ labelPlacement: 'horizontal' }, () => {
assert(wrapper.find('.next-step-label-horizontal').length === 1);
// 横向模式下会调整 next-step-item-tail 的宽度值
const $tail = wrapper.find('.next-step-item-tail');
assert(
$tail.length === 3 &&
$tail.at(0).instance().style.width !== "" &&
$tail.at(2).instance().style.width === ""
);
// 重新设置为垂直居中 应该去掉 next-step-item-tail 的宽度值
wrapper.setProps({labelPlacement: 'ver'}, () => {
assert(
$tail.length === 3 &&
$tail.at(0).instance().style.width === ""
);
});
});
assert(wrapper.find('.next-step-label-horizontal').length === 1);
});

it('should trigger click event', () => {
Expand Down

0 comments on commit 1b00d8f

Please sign in to comment.