@@ -51,6 +51,14 @@ export const _MdcTextFieldMixinBase: CanUpdateErrorStateCtor & typeof MdcTextFie
5151
5252let nextUniqueId = 0 ;
5353
54+ /**
55+ * Time in milliseconds for which to ignore mouse events, after
56+ * receiving a touch event. Used to avoid doing double work for
57+ * touch devices where the browser fires fake mouse events, in
58+ * addition to touch events.
59+ */
60+ const MOUSE_EVENT_IGNORE_TIME = 800 ;
61+
5462@Component ( {
5563 moduleId : module . id ,
5664 selector : 'mdc-text-field' ,
@@ -108,6 +116,9 @@ export class MdcTextField extends _MdcTextFieldMixinBase implements AfterViewIni
108116 private _uid = `mdc-input-${ nextUniqueId ++ } ` ;
109117 private _initialized : boolean = false ;
110118
119+ /** Time in milliseconds when the last touchstart event happened. */
120+ private _lastTouchStartEvent : number = 0 ;
121+
111122 controlType : string = 'mdc-text-field' ;
112123
113124 @Input ( ) label : string | null = null ;
@@ -406,6 +417,17 @@ export class MdcTextField extends _MdcTextFieldMixinBase implements AfterViewIni
406417 }
407418
408419 onInputInteraction ( evt : MouseEvent | TouchEvent ) : void {
420+ if ( evt instanceof MouseEvent ) {
421+ const isSyntheticEvent = this . _lastTouchStartEvent &&
422+ Date . now ( ) < this . _lastTouchStartEvent + MOUSE_EVENT_IGNORE_TIME ;
423+
424+ if ( isSyntheticEvent ) {
425+ return ;
426+ }
427+ } else {
428+ this . _lastTouchStartEvent = Date . now ( ) ;
429+ }
430+
409431 this . _foundation . setTransformOrigin ( evt ) ;
410432 }
411433
0 commit comments