Skip to content
Snippets Groups Projects
Commit 8bb29032 authored by Alexander Reifschneider's avatar Alexander Reifschneider
Browse files

OZG-725 Modify disabled button state

Sub-Task: OZG-7894
parent 49828171
No related branches found
No related tags found
1 merge request!103OZG-725-ui-styling
......@@ -45,7 +45,7 @@ type ButtonVariants = VariantProps<typeof buttonVariants>;
[dataTestId]="dataTestId"
[isLoading]="isLoading"
[disabled]="disabled"
(click)="clickEmitter.emit()"
(clickEmitter)="clickEmitter.emit()"
>
<ng-content icon select="[icon]" />
</ods-button>`,
......
......@@ -41,4 +41,27 @@ describe('ButtonComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});
describe('component', () => {
beforeEach(() => {
component.clickEmitter.emit = jest.fn();
});
describe('onClick', () => {
it('should emit click', () => {
component.onClick();
expect(component.clickEmitter.emit).toHaveBeenCalled();
});
it('should NOT emit click', () => {
component.disabled = true;
fixture.detectChanges();
component.onClick();
expect(component.clickEmitter.emit).not.toHaveBeenCalled();
});
});
});
});
......@@ -91,13 +91,12 @@ export type ButtonVariants = VariantProps<typeof buttonVariants>;
imports: [CommonModule, SpinnerIconComponent],
template: ` <button
type="button"
[ngClass]="buttonVariants({ size, variant, disabled, destructive })"
[disabled]="isDisabled"
[ngClass]="buttonVariants({ size, variant, disabled: isDisabled, destructive })"
[attr.aria-disabled]="isDisabled"
[attr.aria-label]="text"
[attr.data-test-id]="dataTestId"
[attr.data-test-class]="dataTestClass"
(click)="clickEmitter.emit()"
(click)="onClick()"
>
<ng-content *ngIf="!isLoading" select="[icon]"></ng-content>
<ods-spinner-icon *ngIf="isLoading" [size]="spinnerSize" data-test-class="spinner"></ods-spinner-icon>
......@@ -121,5 +120,11 @@ export class ButtonComponent {
return this.disabled || this.isLoading;
}
onClick(): void {
if (!this.isDisabled) {
this.clickEmitter.emit();
}
}
readonly buttonVariants = buttonVariants;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment