Skip to content

Commit ec73097

Browse files
committed
fix: steps v-model can not click
1 parent 9257c1e commit ec73097

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

components/steps/index.jsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ const getStepsProps = (defaultProps = {}) => {
1818
direction: PropTypes.oneOf(['horizontal', 'vertical']),
1919
progressDot: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
2020
type: PropTypes.oneOf(['default', 'navigation']),
21+
onChange: PropTypes.func,
22+
'onUpdate:current': PropTypes.func,
2123
};
2224
return initDefaultProps(props, defaultProps);
2325
};
2426

2527
const Steps = {
2628
name: 'ASteps',
29+
inheritAttrs: false,
2730
props: getStepsProps({
2831
current: 0,
2932
}),
@@ -33,8 +36,14 @@ const Steps = {
3336
};
3437
},
3538
Step: { ...VcSteps.Step, name: 'AStep' },
39+
methods: {
40+
handleChange(current) {
41+
this.$emit('update:current', current);
42+
this.$emit('change', current);
43+
},
44+
},
3645
render() {
37-
const props = getOptionProps(this);
46+
const props = { ...getOptionProps(this), ...this.$attrs };
3847
const { prefixCls: customizePrefixCls, iconPrefix: customizeIconPrefixCls } = props;
3948
const getPrefixCls = this.configProvider.getPrefixCls;
4049
const prefixCls = getPrefixCls('steps', customizePrefixCls);
@@ -51,6 +60,8 @@ const Steps = {
5160
prefixCls,
5261
progressDot,
5362
...props,
63+
canClick: !!(this.onChange || this['onUpdate:current']),
64+
onChange: this.handleChange,
5465
};
5566
return <VcSteps {...stepsProps}>{getSlot(this)}</VcSteps>;
5667
},

components/vc-steps/Steps.jsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import PropTypes from '../_util/vue-types';
22
import BaseMixin from '../_util/BaseMixin';
33
import debounce from 'lodash-es/debounce';
44
import isFlexSupported from '../_util/isFlexSupported';
5-
import { filterEmpty, getSlot, getPropsData } from '../_util/props-util';
5+
import { getSlot, getPropsData } from '../_util/props-util';
66
import { cloneElement } from '../_util/vnode';
77

88
export default {
@@ -23,6 +23,7 @@ export default {
2323
finish: PropTypes.any,
2424
error: PropTypes.any,
2525
}).loose,
26+
canClick: PropTypes.bool,
2627
},
2728
data() {
2829
this.calcStepOffsetWidth = debounce(this.calcStepOffsetWidth, 150);
@@ -59,7 +60,6 @@ export default {
5960
const { current } = this.$props;
6061
if (current !== next) {
6162
this.__emit('change', next);
62-
this.__emit('update:current', next);
6363
}
6464
},
6565
calcStepOffsetWidth() {
@@ -101,10 +101,11 @@ export default {
101101
progressDot,
102102
initial,
103103
icons,
104+
canClick,
104105
} = this;
105106
const isNav = type === 'navigation';
106107
const { lastStepOffsetWidth, flexSupported } = this;
107-
const filteredChildren = filterEmpty(getSlot(this));
108+
const filteredChildren = getSlot(this);
108109
const lastIndex = filteredChildren.length - 1;
109110
const adjustedlabelPlacement = progressDot ? 'vertical' : labelPlacement;
110111
const classString = {
@@ -134,9 +135,7 @@ export default {
134135
icons,
135136
...childProps,
136137
};
137-
138-
const { onChange } = this.$attrs;
139-
if (onChange || this.$attrs['onUpdate:current']) {
138+
if (canClick) {
140139
stepProps.onStepClick = this.onStepClick;
141140
}
142141
if (!flexSupported && direction !== 'vertical') {

0 commit comments

Comments
 (0)