Skip to content

Commit 289e893

Browse files
fix(IgxMask): return when IE triggers input before focus
1 parent 459b845 commit 289e893

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

projects/igniteui-angular/src/lib/directives/mask/mask.directive.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export class IgxMaskDirective implements OnInit, AfterViewChecked, ControlValueA
154154
/** @hidden */
155155
public ngOnInit(): void {
156156
if (!this.nativeElement.placeholder) {
157-
this.renderer.setAttribute(this.nativeElement, 'placeholder', this.maskOptions.format);
157+
this.renderer.setAttribute(this.nativeElement, 'placeholder', this.maskOptions.format);
158158
}
159159
}
160160

@@ -188,7 +188,15 @@ export class IgxMaskDirective implements OnInit, AfterViewChecked, ControlValueA
188188
/** @hidden */
189189
@HostListener('input')
190190
public onInputChanged(): void {
191-
if (isIE() && this._stopPropagation) {
191+
/**
192+
* '!this._focused' is a fix for #8165
193+
* On page load IE triggers input events before focus events and
194+
* it does so for every single input on the page.
195+
* The mask needs to be prevented from doing anything while this is happening because
196+
* the end user will be unable to blur the input.
197+
* https://stackoverflow.com/questions/21406138/input-event-triggered-on-internet-explorer-when-placeholder-changed
198+
*/
199+
if (isIE() && (this._stopPropagation || !this._focused)) {
192200
this._stopPropagation = false;
193201
return;
194202
}

0 commit comments

Comments
 (0)