Skip to content

Commit 44a1913

Browse files
refactor(igxMask): show/hide mask on dragenter/dragleave
1 parent 08b91db commit 44a1913

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -318,19 +318,25 @@ describe('igxMask', () => {
318318
expect(input.nativeElement.value).toEqual('(457) 6___-___');
319319
}));
320320

321-
it('Should display mask on dragover', fakeAsync(() => {
321+
it('Should display mask on dragenter and remove it on dragleave', fakeAsync(() => {
322322
const fixture = TestBed.createComponent(EmptyMaskTestComponent);
323323
fixture.detectChanges();
324324
const input = fixture.componentInstance.input;
325325

326326
expect(input.nativeElement.value).toEqual('');
327327
expect(input.nativeElement.placeholder).toEqual('CCCCCCCCCC');
328328

329-
input.nativeElement.dispatchEvent(new DragEvent('dragover'));
329+
input.nativeElement.dispatchEvent(new DragEvent('dragenter'));
330330
fixture.detectChanges();
331331
tick();
332332

333333
expect(input.nativeElement.value).toEqual('__________');
334+
335+
input.nativeElement.dispatchEvent(new DragEvent('dragleave'));
336+
fixture.detectChanges();
337+
tick();
338+
339+
expect(input.nativeElement.value).toEqual('');
334340
}));
335341

336342
it('Apply display and input pipes on blur and focus.', fakeAsync(() => {

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,17 @@ export class IgxMaskDirective implements OnInit, AfterViewChecked, ControlValueA
225225
}
226226

227227
/** @hidden */
228-
@HostListener('dragover')
229-
public onDragOver(): void {
228+
@HostListener('dragenter')
229+
public onDragEnter(): void {
230230
this.showMask('');
231231
}
232232

233+
/** @hidden */
234+
@HostListener('dragleave')
235+
public onDragLeave(): void {
236+
this.inputValue = '';
237+
}
238+
233239
/** @hidden */
234240
@HostListener('drop', ['$event'])
235241
public onDrop(event: DragEvent): void {

0 commit comments

Comments
 (0)