Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FocusOriginMonitor): support monitoring subtree focus as well as element #3113

Merged
merged 5 commits into from
Feb 16, 2017

Conversation

mmalerba
Copy link
Contributor

Also includes some cleanup:

  • rename registerElementForFocusClasses to monitor
  • add unmonitor method and call on directive destroyed
  • do all listening outside angular
  • replace cdkFocusClasses with cdkMonitorElementFocus and cdkMonitorSubtreeFocus

@mmalerba mmalerba requested a review from devversion February 15, 2017 20:55
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Feb 15, 2017
// Create monitored element info.
let info: MonitoredElementInfo = {
unlisten: null,
includesChildren: includeChildren,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about checkChildren?

// focused element.
window.addEventListener('focus', () => {
this._windowFocused = true;
setTimeout(() => this._windowFocused = false, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an optional nit. How about extracting this into its own function?

constructor(ngZone: NgZone) {
  ngZone.runOutsideAngular(() => this._registerDocumentEvents());
}

This way we would get rid of unnecessary indentation and also have it pretty clean.

Copy link
Member

@devversion devversion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. One small nit.


// If we are not counting child-element-focus as focused, make sure that the event target is the
// monitored element itself.
if (!this._elementInfo.get(element).checkChildren && element != event.target) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should use === as often as possible. Also in the setClasses method.

@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Feb 16, 2017
@andrewseguin andrewseguin merged commit 3b39bd2 into angular:master Feb 16, 2017
@mmalerba mmalerba deleted the fc branch July 31, 2018 21:19
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants