Skip to content

Commit

Permalink
fix(Step): labelPlacement value change dbl times
Browse files Browse the repository at this point in the history
  • Loading branch information
zobor committed Mar 11, 2019
1 parent 0b93378 commit 3c7ae73
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 3c7ae73

Please sign in to comment.