fix(stepper): add disabled state to prevent navigation and provide visual feedback
This commit is contained in:
@@ -18,9 +18,12 @@ import { NgClass } from '@angular/common';
|
||||
export class StepperComponent {
|
||||
readonly steps = contentChildren(StepComponent);
|
||||
readonly initialStepIndex = input(0);
|
||||
readonly disabled = input(false);
|
||||
readonly currentStepIndex = linkedSignal(() => this.initialStepIndex());
|
||||
|
||||
next() {
|
||||
if (this.disabled()) return;
|
||||
|
||||
const currentSteps = this.steps();
|
||||
const currentIndex = this.currentStepIndex();
|
||||
if (currentIndex < currentSteps.length - 1) {
|
||||
@@ -32,6 +35,8 @@ export class StepperComponent {
|
||||
}
|
||||
|
||||
previous() {
|
||||
if (this.disabled()) return;
|
||||
|
||||
const currentIndex = this.currentStepIndex();
|
||||
if (currentIndex > 0) {
|
||||
this.currentStepIndex.set(currentIndex - 1);
|
||||
@@ -39,6 +44,8 @@ export class StepperComponent {
|
||||
}
|
||||
|
||||
goToStep(index: number) {
|
||||
if (this.disabled()) return;
|
||||
|
||||
const targetIndex = index;
|
||||
// Only allow navigating to completed steps or the current one
|
||||
if (targetIndex < this.currentStepIndex()) {
|
||||
|
||||
Reference in New Issue
Block a user