File tree Expand file tree Collapse file tree 2 files changed +24
-5
lines changed
Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,27 @@ import {
2121
2222export class Link {
2323 @HostBinding ( "class.bx--link" ) baseClass = true ;
24+
2425 /**
25- * Set to `true` to disable link.
26+ * Automatically set to `-1` when link is disabled .
2627 * @memberof Link
2728 */
28- @HostBinding ( "attr.aria-disabled" ) @Input ( ) disabled = false ;
29+ @HostBinding ( "attr.tabindex" ) tabindex ;
30+
31+ /**
32+ * Set to true to disable link.
33+ * @memberof Link
34+ */
35+ @Input ( )
36+ @HostBinding ( "attr.aria-disabled" )
37+ set disabled ( disabled : boolean ) {
38+ this . _disabled = disabled ;
39+ this . tabindex = this . disabled ? - 1 : null ;
40+ }
41+
42+ get disabled ( ) : boolean {
43+ return this . _disabled ;
44+ }
45+
46+ private _disabled ;
2947}
Original file line number Diff line number Diff line change @@ -17,7 +17,8 @@ describe("Link", () => {
1717 expect ( component ) . toBeTruthy ( ) ;
1818 const directiveEl = fixture . debugElement . query ( By . directive ( Link ) ) ;
1919 expect ( directiveEl ) . not . toBeNull ( ) ;
20- expect ( directiveEl . attributes [ "aria-disabled" ] ) . toBe ( "false" ) ;
20+ expect ( directiveEl . attributes [ "aria-disabled" ] ) . toBe ( null ) ;
21+ expect ( directiveEl . attributes [ "tabindex" ] ) . toBe ( null ) ;
2122 expect ( directiveEl . attributes [ "href" ] ) . toBe ( "https://angular.carbondesignsystem.com/" ) ;
2223 } ) ;
2324
@@ -31,8 +32,8 @@ describe("Link", () => {
3132 fixture . detectChanges ( ) ;
3233
3334 const directiveEl = fixture . debugElement . query ( By . directive ( Link ) ) ;
34- expect ( directiveEl . attributes [ "disabled" ] ) . toBe ( "true" ) ;
3535 expect ( directiveEl . attributes [ "aria-disabled" ] ) . toBe ( "true" ) ;
36+ expect ( directiveEl . attributes [ "tabindex" ] ) . toBe ( "-1" ) ;
3637 } ) ;
3738} ) ;
3839
@@ -43,7 +44,7 @@ class TestLinkComponent {
4344}
4445
4546@Component ( {
46- template : `<a href="https://angular.carbondesignsystem.com/" disabled="true " ibmLink>link</a>`
47+ template : `<a href="https://angular.carbondesignsystem.com/" [ disabled]="1+1===2 " ibmLink>link</a>`
4748} )
4849class TestDisabledLinkComponent {
4950}
You can’t perform that action at this time.
0 commit comments