Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

(v1 backport) [NG] fix button title for button group (#3136) #3151

Merged
merged 1 commit into from Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions golden/clr-angular.d.ts
Expand Up @@ -104,6 +104,7 @@ export declare class ClrButton implements LoadingListener {
buttonInGroupService: ButtonInGroupService;
classNames: string;
disabled: any;
id: string;
inMenu: boolean;
loading: boolean;
name: string;
Expand Down
14 changes: 14 additions & 0 deletions src/clr-angular/button/button-group/button.spec.ts
Expand Up @@ -21,6 +21,7 @@ import { ClrButtonGroupModule } from './button-group.module';
id="button1"
type="button"
name="button1"
id="button1"
(click)="toggleClick()">Button 1
</clr-button>
<clr-button
Expand Down Expand Up @@ -65,6 +66,7 @@ class TestButtonComponent {
class="test"
type="button"
name="button3"
id="button3"
#button3
>Test Button 3
</clr-button>
Expand Down Expand Up @@ -132,6 +134,12 @@ export default function(): void {
expect(componentInstance.button3.name).toBeNull();
});

it('supports a id input', () => {
expect(componentInstance.button1.id).toBe('button1');
expect(componentInstance.button2.id).toBeNull();
expect(componentInstance.button3.id).toBeNull();
});

it('supports a disabled input which is set to an empty string when the user passes a value', () => {
expect(componentInstance.button1.disabled).toBeNull();
expect(componentInstance.button2.disabled).toBeNull();
Expand Down Expand Up @@ -246,6 +254,12 @@ export default function(): void {
expect(buttons[2].name).toBe('button3');
});

it('sets the id correctly', () => {
expect(buttons[0].id).toBe('null');
expect(buttons[1].id).toBe('null');
expect(buttons[2].id).toBe('button3');
});

it('sets the type correctly', () => {
expect(buttons[0].type).toBe('submit'); // default
expect(buttons[1].type).toBe('submit'); // default
Expand Down
16 changes: 15 additions & 1 deletion src/clr-angular/button/button-group/button.ts
Expand Up @@ -19,7 +19,8 @@ import { ButtonInGroupService } from '../providers/button-in-group.service';
(click)="emitClick()"
[attr.type]="type"
[attr.name]="name"
[attr.disabled]="disabled">
[attr.disabled]="disabled"
[id]="id">
<span class="spinner spinner-inline" *ngIf="loading"></span>
<ng-content></ng-content>
</button>
Expand Down Expand Up @@ -100,6 +101,19 @@ export class ClrButton implements LoadingListener {
}
}

private _id: string = null;

get id(): string {
return this._id;
}

@Input('id')
set id(value: string) {
if (typeof value === 'string') {
this._id = value;
}
}

private _disabled: any = null;

get disabled(): any {
Expand Down