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): add support for touch events #3020

Merged
merged 7 commits into from
Feb 14, 2017

Conversation

mmalerba
Copy link
Contributor

@mmalerba mmalerba commented Feb 9, 2017

No description provided.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Feb 9, 2017
@@ -3,7 +3,10 @@ import {Observable} from 'rxjs/Observable';
import {Subject} from 'rxjs/Subject';


export type FocusOrigin = 'mouse' | 'keyboard' | 'program';
const TOUCH_BUFFER_MS = 650;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@devversion I stole this number from material 1, but any idea where it comes from?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think the timeout is still fine. I took it from angular/material#7965 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

Also mind exporting this variable? So the tests can use it for their setTimeout's?

@mmalerba
Copy link
Contributor Author

@devversion I've made the change to compare event targets that you were asking for. While it is a little simpler, I believe it is less correct than what I had previously. Consider this example:

<div tabindex=1 #d cdkFocusClasses>
    <button (click)="d.focus()"></button>
</div>

Here the div will be given the cdk-touch-focused when the button is touched. This is technically incorrect, though I admit it is a very small edge case. So its a question of whether we keep the simpler almost correct solution or go with the more complicated but more correct solution.

@devversion
Copy link
Member

devversion commented Feb 11, 2017

@mmalerba I see. I just ran your PR locally on my end and saw the issue.

I went through the _wasCausedByTouch logic again and I'm pretty sure that we could remove the .contains check here.

Prop Description
TouchEvent.target Target is always type of Element and can be stored
FocusEvent.target If the same as TouchEvent.target then it was caused by touch.
Focus will only happen if the element is explicitly touched. No subtree handling necessary

This would also solve the issue you mentioned above.

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 - We had a discussion again and the current approach works fine (Miles will add a comment)

@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Feb 13, 2017
@andrewseguin andrewseguin merged commit ec7e2e4 into angular:master Feb 14, 2017
@mmalerba mmalerba deleted the fc2 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.

5 participants