Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(button): add the focus() method to buttons. #643

Merged
merged 1 commit into from
Jun 6, 2016
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/components/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ export class MdButton {
removeKeyboardFocus() {
this.isKeyboardFocused = false;
}

/** TODO(hansl): e2e test this function. */
focus() {
this.elementRef.nativeElement.focus();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a TODO to add an e2e test for this? (simulating focus in a unit test doesn't really work well)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

}

@Component({
Expand Down
9 changes: 6 additions & 3 deletions src/demo-app/button/button-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,14 @@
<div>
<p>isDisabled: {{isDisabled}}, clickCounter: <span id="clickCounter">{{clickCounter}}</span></p>
<button md-raised-button (click)="isDisabled=!isDisabled" id="disableToggle">Disable buttons</button>
<button md-raised-button (click)="button1.focus()" id="disableToggle">Focus 1</button>
<button md-raised-button (click)="button2.focus()" id="disableToggle">Focus 2</button>
<button md-raised-button (click)="button3.focus()" id="disableToggle">Focus 3</button>
</div>
<button md-button [disabled]="isDisabled" (click)="clickCounter=clickCounter+1" id="testButton">off</button>
<button md-button #button1 [disabled]="isDisabled" (click)="clickCounter=clickCounter+1" id="testButton">off</button>
<button md-button color="primary" [disabled]="isDisabled">off</button>
<a href="http://www.google.com" md-button color="accent" [disabled]="isDisabled">off</a>
<button md-raised-button color="primary" [disabled]="isDisabled">off</button>
<a href="http://www.google.com" #button2 md-button color="accent" [disabled]="isDisabled">off</a>
<button md-raised-button #button3 color="primary" [disabled]="isDisabled">off</button>
<button md-mini-fab [disabled]="isDisabled">
<md-icon class="md-24">check</md-icon>
</button>
Expand Down