Skip to content

Commit

Permalink
feat(FocusOriginMonitor): support monitoring subtree focus as well as…
Browse files Browse the repository at this point in the history
… element (#3113)

* focus origin monitor improvements

* addressed comment + tests

* addressed comments and replaced Observable w/ EventEmitter

* simplify fat arrow

* rename the files now that the directive name has changed
  • Loading branch information
mmalerba authored and andrewseguin committed Feb 16, 2017
1 parent c332b50 commit 3b39bd2
Show file tree
Hide file tree
Showing 6 changed files with 549 additions and 289 deletions.
14 changes: 13 additions & 1 deletion src/demo-app/style/style-demo.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<button #b class="demo-button" cdkFocusClasses>focus me!</button>
<button #b class="demo-focusable" cdkMonitorElementFocus>focus me!</button>
<button (click)="b.focus()">focus programmatically</button>

<button (click)="fom.focusVia(b, renderer, 'mouse')">focusVia: mouse</button>
Expand All @@ -7,3 +7,15 @@
<button (click)="fom.focusVia(b, renderer, 'program')">focusVia: program</button>

<div>Active classes: {{b.classList}}</div>

<br>

<div class="demo-focusable" tabindex="0" cdkMonitorElementFocus>
<p>div with element focus monitored</p>
<button>1</button><button>2</button>
</div>

<div class="demo-focusable" tabindex="0" cdkMonitorSubtreeFocus>
<p>div with subtree focus monitored</p>
<button>1</button><button>2</button>
</div>
10 changes: 5 additions & 5 deletions src/demo-app/style/style-demo.scss
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
.demo-button.cdk-focused {
.demo-focusable.cdk-focused {
border: 2px solid red;
}

.demo-button.cdk-mouse-focused {
.demo-focusable.cdk-mouse-focused {
background: green;
}

.demo-button.cdk-keyboard-focused {
.demo-focusable.cdk-keyboard-focused {
background: yellow;
}

.demo-button.cdk-program-focused {
.demo-focusable.cdk-program-focused {
background: blue;
}

.demo-button.cdk-touch-focused {
.demo-focusable.cdk-touch-focused {
background: purple;
}
183 changes: 0 additions & 183 deletions src/lib/core/style/focus-classes.ts

This file was deleted.

Loading

0 comments on commit 3b39bd2

Please sign in to comment.