Skip to content

Commit

Permalink
fix(ref: no-ref): fix issues
Browse files Browse the repository at this point in the history
* fix(ref: no-ref): fix issues

* fix(ref: no-ref): fix bugs

* fix(ref: no-ref): fix bugs
  • Loading branch information
andriikamaldinov1 authored Jul 5, 2024
1 parent c693df8 commit 0249c92
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 12 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 17.1.1(2024-07-05)

### Fix

- Fix ([#1383](https://github.com/JsDaddy/ngx-mask/issues/1383))


# 17.1.0(2024-07-05)

### Fix
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-mask",
"version": "17.1.0",
"version": "17.1.1",
"description": "Awesome ngx mask",
"license": "MIT",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-mask-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-mask",
"version": "17.1.0",
"version": "17.1.1",
"description": "awesome ngx mask",
"keywords": [
"ng2-mask",
Expand Down
9 changes: 3 additions & 6 deletions projects/ngx-mask-lib/src/lib/ngx-mask-applier.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,16 +504,14 @@ export class NgxMaskApplierService {
(!maskStartWithMonth &&
(Number(inputValueSliceCursorPlusTwo) > daysCount ||
Number(inputValueSliceMinusOnePlusOne) > daysCount ||
(this.specialCharacters.includes(inputValueCursorPlusOne) &&
!backspaced))) ||
this.specialCharacters.includes(inputValueCursorPlusOne))) ||
(startWithMonthInput
? Number(inputValueSliceMinusOnePlusOne) > daysCount ||
(!this.specialCharacters.includes(inputValueCursor) &&
this.specialCharacters.includes(inputValueCursorPlusTwo)) ||
this.specialCharacters.includes(inputValueCursor)
: Number(inputValueSliceCursorPlusTwo) > daysCount ||
(this.specialCharacters.includes(inputValueCursorPlusOne) &&
!backspaced))
this.specialCharacters.includes(inputValueCursorPlusOne))
) {
// eslint-disable-next-line no-param-reassign
position = !this.leadZeroDateTime ? position + 1 : position;
Expand Down Expand Up @@ -556,8 +554,7 @@ export class NgxMaskApplierService {
) &&
this.specialCharacters.includes(inputValueCursorMinusOne) &&
(Number(inputValueSliceCursorPlusTwo) > monthsCount ||
(this.specialCharacters.includes(inputValueCursorPlusOne) &&
!backspaced));
this.specialCharacters.includes(inputValueCursorPlusOne));
// cursor === 5 && without days
const day2monthInputDot: boolean =
(Number(inputValueSliceCursorPlusTwo) > monthsCount && cursor === 5) ||
Expand Down
77 changes: 73 additions & 4 deletions projects/ngx-mask-lib/src/test/delete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('Directive: Mask (Delete)', () => {
key: 'Backspace',
keyCode: 8,
target: inputTarget,
// eslint-disable-next-line @typescript-eslint/no-empty-function

preventDefault: () => {},
});
debugElement.triggerEventHandler('input', { target: inputTarget });
Expand All @@ -185,7 +185,7 @@ describe('Directive: Mask (Delete)', () => {
key: 'Backspace',
keyCode: 8,
target: inputTarget,
// eslint-disable-next-line @typescript-eslint/no-empty-function

preventDefault: () => {},
});
debugElement.triggerEventHandler('input', { target: inputTarget });
Expand All @@ -208,7 +208,7 @@ describe('Directive: Mask (Delete)', () => {
key: 'Backspace',
keyCode: 8,
target: inputTarget,
// eslint-disable-next-line @typescript-eslint/no-empty-function

preventDefault: () => {},
});
debugElement.triggerEventHandler('input', { target: inputTarget });
Expand All @@ -231,10 +231,79 @@ describe('Directive: Mask (Delete)', () => {
key: 'Backspace',
keyCode: 8,
target: inputTarget,
// eslint-disable-next-line @typescript-eslint/no-empty-function

preventDefault: () => {},
});
debugElement.triggerEventHandler('input', { target: inputTarget });
expect(inputTarget.selectionStart).toEqual(3);
});

it('date mask should show keep right value d0/M0/0000', () => {
component.mask = 'd0/M0/0000';
const inputElement = fixture.nativeElement.querySelector('input');

inputElement.value = '4/4/4444';
inputElement.dispatchEvent(new Event('input'));
fixture.detectChanges();

inputElement.setSelectionRange(8, 8);
inputElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'Backspace' }));
inputElement.value = '4/4/444';
inputElement.setSelectionRange(7, 7);
inputElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'Backspace' }));
inputElement.value = '4/4/44';
inputElement.setSelectionRange(6, 6);
inputElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'Backspace' }));
inputElement.value = '4/4/4';
inputElement.dispatchEvent(new Event('input'));
fixture.detectChanges();

expect(inputElement.value).toBe('4/4/4');
});

it('date mask should show keep right value d0:M0:0000', () => {
component.mask = 'd0:M0:0000';
const inputElement = fixture.nativeElement.querySelector('input');

inputElement.value = '4:4:4444';
inputElement.dispatchEvent(new Event('input'));
fixture.detectChanges();

inputElement.setSelectionRange(8, 8);
inputElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'Backspace' }));
inputElement.value = '4:4:444';
inputElement.setSelectionRange(7, 7);
inputElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'Backspace' }));
inputElement.value = '4:4:44';
inputElement.setSelectionRange(6, 6);
inputElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'Backspace' }));
inputElement.value = '4:4:4';
inputElement.dispatchEvent(new Event('input'));
fixture.detectChanges();

expect(inputElement.value).toBe('4:4:4');
});

it('date mask should show keep right value d0-M0-0000', () => {
component.mask = 'd0-M0-0000';
const inputElement = fixture.nativeElement.querySelector('input');

inputElement.value = '4-4-4444';
inputElement.dispatchEvent(new Event('input'));
fixture.detectChanges();

inputElement.setSelectionRange(8, 8);
inputElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'Backspace' }));
inputElement.value = '4-4-444';
inputElement.setSelectionRange(7, 7);
inputElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'Backspace' }));
inputElement.value = '4-4-44';
inputElement.setSelectionRange(6, 6);
inputElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'Backspace' }));
inputElement.value = '4-4-4';
inputElement.dispatchEvent(new Event('input'));
fixture.detectChanges();

expect(inputElement.value).toBe('4-4-4');
});
});

0 comments on commit 0249c92

Please sign in to comment.