diff --git a/src/lib/list/list.spec.ts b/src/lib/list/list.spec.ts
index b266b38517b1..5bc594c0b38d 100644
--- a/src/lib/list/list.spec.ts
+++ b/src/lib/list/list.spec.ts
@@ -28,18 +28,19 @@ describe('MdList', () => {
it('should add and remove focus class on focus/blur', () => {
let fixture = TestBed.createComponent(ListWithOneAnchorItem);
- let listItem = fixture.debugElement.query(By.directive(MdListItem));
- let listItemDiv = fixture.debugElement.query(By.css('.mat-list-item-content'));
fixture.detectChanges();
- expect(listItemDiv.nativeElement.classList).not.toContain('mat-list-item-focus');
+ let listItem = fixture.debugElement.query(By.directive(MdListItem));
+ let listItemEl = fixture.debugElement.query(By.css('.mat-list-item'));
+
+ expect(listItemEl.nativeElement.classList).not.toContain('mat-list-item-focus');
listItem.componentInstance._handleFocus();
fixture.detectChanges();
- expect(listItemDiv.nativeElement.classList).toContain('mat-list-item-focus');
+ expect(listItemEl.nativeElement.classList).toContain('mat-list-item-focus');
listItem.componentInstance._handleBlur();
fixture.detectChanges();
- expect(listItemDiv.nativeElement.classList).not.toContain('mat-list-item-focus');
+ expect(listItemEl.nativeElement.classList).not.toContain('mat-list-item-focus');
});
it('should not apply any additional class to a list without lines', () => {
diff --git a/src/lib/list/list.ts b/src/lib/list/list.ts
index 11fb7c4c288b..a8e7501be1d5 100644
--- a/src/lib/list/list.ts
+++ b/src/lib/list/list.ts
@@ -1,17 +1,17 @@
import {
+ AfterContentInit,
Component,
- ViewEncapsulation,
- ContentChildren,
ContentChild,
- QueryList,
+ ContentChildren,
Directive,
ElementRef,
Input,
Optional,
+ QueryList,
Renderer2,
- AfterContentInit,
+ ViewEncapsulation
} from '@angular/core';
-import {MdLine, MdLineSetter, coerceBooleanProperty} from '../core';
+import {coerceBooleanProperty, MdLine, MdLineSetter} from '../core';
@Directive({
selector: 'md-divider, mat-divider'
@@ -128,8 +128,6 @@ export class MdListItem implements AfterContentInit {
private _disableRipple: boolean = false;
private _isNavList: boolean = false;
- _hasFocus: boolean = false;
-
/**
* Whether the ripple effect on click should be disabled. This applies only to list items that are
* part of a nav list. The value of `disableRipple` on the `md-nav-list` overrides this flag.
@@ -166,11 +164,11 @@ export class MdListItem implements AfterContentInit {
}
_handleFocus() {
- this._hasFocus = true;
+ this._renderer.addClass(this._element.nativeElement, 'mat-list-item-focus');
}
_handleBlur() {
- this._hasFocus = false;
+ this._renderer.removeClass(this._element.nativeElement, 'mat-list-item-focus');
}
/** Retrieves the DOM element of the component host. */
diff --git a/src/lib/sidenav/sidenav.ts b/src/lib/sidenav/sidenav.ts
index fa1acb75f05d..bb86c2311307 100644
--- a/src/lib/sidenav/sidenav.ts
+++ b/src/lib/sidenav/sidenav.ts
@@ -133,7 +133,7 @@ export class MdSidenav implements AfterContentInit, OnDestroy {
this._elementFocusedBeforeSidenavWasOpened = document.activeElement as HTMLElement;
if (this.isFocusTrapEnabled && this._focusTrap) {
- this._focusTrap.focusFirstTabbableElementWhenReady();
+ this._focusTrap.focusInitialElementWhenReady();
}
});