Skip to content

Commit 3b39bd2

Browse files
mmalerbaandrewseguin
authored andcommitted
feat(FocusOriginMonitor): support monitoring subtree focus as well as 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
1 parent c332b50 commit 3b39bd2

File tree

6 files changed

+549
-289
lines changed

6 files changed

+549
-289
lines changed

src/demo-app/style/style-demo.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<button #b class="demo-button" cdkFocusClasses>focus me!</button>
1+
<button #b class="demo-focusable" cdkMonitorElementFocus>focus me!</button>
22
<button (click)="b.focus()">focus programmatically</button>
33

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

99
<div>Active classes: {{b.classList}}</div>
10+
11+
<br>
12+
13+
<div class="demo-focusable" tabindex="0" cdkMonitorElementFocus>
14+
<p>div with element focus monitored</p>
15+
<button>1</button><button>2</button>
16+
</div>
17+
18+
<div class="demo-focusable" tabindex="0" cdkMonitorSubtreeFocus>
19+
<p>div with subtree focus monitored</p>
20+
<button>1</button><button>2</button>
21+
</div>

src/demo-app/style/style-demo.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
.demo-button.cdk-focused {
1+
.demo-focusable.cdk-focused {
22
border: 2px solid red;
33
}
44

5-
.demo-button.cdk-mouse-focused {
5+
.demo-focusable.cdk-mouse-focused {
66
background: green;
77
}
88

9-
.demo-button.cdk-keyboard-focused {
9+
.demo-focusable.cdk-keyboard-focused {
1010
background: yellow;
1111
}
1212

13-
.demo-button.cdk-program-focused {
13+
.demo-focusable.cdk-program-focused {
1414
background: blue;
1515
}
1616

17-
.demo-button.cdk-touch-focused {
17+
.demo-focusable.cdk-touch-focused {
1818
background: purple;
1919
}

src/lib/core/style/focus-classes.ts

Lines changed: 0 additions & 183 deletions
This file was deleted.

0 commit comments

Comments
 (0)