Skip to content

Commit 39be059

Browse files
committed
review stuff
1 parent c224483 commit 39be059

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/cdk-experimental/popover-edit/edit-event-dispatcher.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ export class EditEventDispatcher {
3232
readonly mouseMove = new Subject<Element|null>();
3333

3434
/** The EditRef for the currently active edit lens (if any). */
35-
editRef: EditRef<any> | null = null;
35+
get editRef(): EditRef<any>|null {
36+
return this._editRef;
37+
}
38+
private _editRef: EditRef<any>|null = null;
3639

3740
/** The table cell that has an active edit lens (or null). */
3841
private _currentlyEditing: Element|null = null;
@@ -71,6 +74,20 @@ export class EditEventDispatcher {
7174
}
7275
}
7376

77+
/** Sets the currently active EditRef. */
78+
setActiveEditRef(ref: EditRef<any>) {
79+
this._editRef = ref;
80+
}
81+
82+
/** Unsets the currently active EditRef, if the specified editRef is active. */
83+
unsetActiveEditRef(ref: EditRef<any>) {
84+
if (this._editRef !== ref) {
85+
return;
86+
}
87+
88+
this._editRef = null;
89+
}
90+
7491
/**
7592
* Gets an Observable that emits true when the specified element's row
7693
* is being hovered over and false when not. Hovering is defined as when

src/cdk-experimental/popover-edit/edit-ref.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class EditRef<FormValue> implements OnDestroy {
4242
constructor(
4343
@Self() private readonly _form: ControlContainer,
4444
private readonly _editEventDispatcher: EditEventDispatcher) {
45-
this._editEventDispatcher.editRef = this;
45+
this._editEventDispatcher.setActiveEditRef(this);
4646
}
4747

4848
/**
@@ -63,7 +63,7 @@ export class EditRef<FormValue> implements OnDestroy {
6363
}
6464

6565
ngOnDestroy(): void {
66-
this._editEventDispatcher.editRef = null;
66+
this._editEventDispatcher.unsetActiveEditRef(this);
6767
this._finalValueSubject.next(this._form.value);
6868
this._finalValueSubject.complete();
6969
}

src/cdk-experimental/popover-edit/focus-escape-notifier.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export class FocusEscapeNotifier extends FocusTrap {
3131
document: Document) {
3232
super(element, checker, ngZone, document, true /* deferAnchors */);
3333

34+
// The focus trap adds "anchors" at the beginning and end of a trapped region that redirect
35+
// focus. We override that redirect behavior here with simply emitting on a stream.
3436
this.startAnchorListener = () => {
3537
this._escapeSubject.next(FocusEscapeNotifierDirection.START);
3638
return true;

0 commit comments

Comments
 (0)