14
14
@click =" () => handleStepClick(index + 1)"
15
15
:class =" [
16
16
'relative outline-none flex h-8 w-8 items-center justify-center rounded-full font-semibold',
17
- isCompleted ? 'cursor-default' : 'cursor-pointer'
17
+ isCompleted && lockOnComplete ? 'cursor-default' : 'cursor-pointer'
18
18
]"
19
19
:style =" getStepIndicatorStyle(index + 1)"
20
20
>
@@ -154,6 +154,7 @@ interface StepperProps {
154
154
nextButtonText? : string ;
155
155
disableStepIndicators? : boolean ;
156
156
renderStepIndicator? : Component ;
157
+ lockOnComplete? : boolean ;
157
158
}
158
159
159
160
const props = withDefaults (defineProps <StepperProps >(), {
@@ -169,7 +170,8 @@ const props = withDefaults(defineProps<StepperProps>(), {
169
170
backButtonText: ' Back' ,
170
171
nextButtonText: ' Continue' ,
171
172
disableStepIndicators: false ,
172
- renderStepIndicator: undefined
173
+ renderStepIndicator: undefined ,
174
+ lockOnComplete: true
173
175
});
174
176
175
177
const slots = useSlots ();
@@ -212,15 +214,15 @@ const getStepContentExit = () => ({
212
214
});
213
215
214
216
const handleStepClick = (step : number ) => {
215
- if (isCompleted .value ) return ;
217
+ if (isCompleted .value && props . lockOnComplete ) return ;
216
218
if (! props .disableStepIndicators ) {
217
219
direction .value = step > currentStep .value ? 1 : - 1 ;
218
220
updateStep (step );
219
221
}
220
222
};
221
223
222
224
const handleCustomStepClick = (clicked : number ) => {
223
- if (isCompleted .value ) return ;
225
+ if (isCompleted .value && props . lockOnComplete ) return ;
224
226
if (clicked !== currentStep .value && ! props .disableStepIndicators ) {
225
227
direction .value = clicked > currentStep .value ? 1 : - 1 ;
226
228
updateStep (clicked );
@@ -259,12 +261,18 @@ const handleComplete = () => {
259
261
props .onFinalStepCompleted ?.();
260
262
};
261
263
262
- watch (currentStep , newStep => {
263
- props .onStepChange ?.(newStep );
264
- if (! isCompleted .value ) {
265
- measureHeight ();
264
+ watch (
265
+ currentStep ,
266
+ (newStep , oldStep ) => {
267
+ props .onStepChange ?.(newStep );
268
+ if (newStep !== oldStep && ! isCompleted .value ) {
269
+ nextTick (measureHeight );
270
+ } else if (! props .lockOnComplete && isCompleted .value ) {
271
+ isCompleted .value = false ;
272
+ nextTick (measureHeight );
273
+ }
266
274
}
267
- } );
275
+ );
268
276
269
277
onMounted (() => {
270
278
if (props .initialStep !== 1 ) {
0 commit comments