fix(stepper): add disabled state to prevent navigation and provide visual feedback

This commit is contained in:
2026-08-24 14:07:12 -03:00
parent 7fbdd3844f
commit 8861e42fff
5 changed files with 53 additions and 8 deletions

View File

@@ -6,7 +6,7 @@ import { StepComponent } from './step.component';
@Component({
imports: [StepperComponent, StepComponent],
template: `
<app-stepper #stepper>
<app-stepper #stepper [disabled]="stepperDisabled()">
<app-step label="Step 1" [isValid]="step1Valid()">
<div id="content-1">Content 1</div>
</app-step>
@@ -20,6 +20,7 @@ class TestHostComponent {
@ViewChild('stepper') stepper!: StepperComponent;
step1Valid = signal(true);
step2Valid = signal(true);
stepperDisabled = signal(false);
}
describe('StepperComponent & StepComponent', () => {
@@ -137,4 +138,28 @@ describe('StepperComponent & StepComponent', () => {
expect(component.stepper.currentStepIndex()).toBe(0);
expect(fixture.nativeElement.querySelector('#content-1')).not.toBeNull();
});
it('blocks all navigation and shows visual feedback while disabled', async () => {
const { fixture, component } = await setup();
component.stepperDisabled.set(true);
fixture.detectChanges();
component.stepper.next();
expect(component.stepper.currentStepIndex()).toBe(0);
component.stepperDisabled.set(false);
fixture.detectChanges();
component.stepper.next();
expect(component.stepper.currentStepIndex()).toBe(1);
component.stepperDisabled.set(true);
fixture.detectChanges();
component.stepper.previous();
component.stepper.goToStep(0);
expect(component.stepper.currentStepIndex()).toBe(1);
const header = fixture.nativeElement.querySelector('.stepper-header');
expect(header.classList.contains('is-disabled')).toBe(true);
expect(header.getAttribute('aria-disabled')).toBe('true');
});
});