Skip to content

Commit

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

* fix(ref: no-ref): fix issue
  • Loading branch information
andriikamaldinov1 authored Jul 17, 2024
1 parent d4006f8 commit ae0d5f8
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 17.1.6(2024-07-16)

### Fix

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

# 17.1.5(2024-07-16)

### 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.5",
"version": "17.1.6",
"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.5",
"version": "17.1.6",
"description": "awesome ngx mask",
"keywords": [
"ng2-mask",
Expand Down
8 changes: 7 additions & 1 deletion projects/ngx-mask-lib/src/lib/ngx-mask.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ export class NgxMaskService extends NgxMaskApplierService {
Boolean(newInputValue) && newInputValue.length ? newInputValue : inputValue;
}

if (this.showMaskTyped && this.keepCharacterPositions && this.actualValue && !justPasted) {
if (
this.showMaskTyped &&
this.keepCharacterPositions &&
this.actualValue &&
!justPasted &&
!this.writingValue
) {
const value = this.dropSpecialCharacters
? this.removeMask(this.actualValue)
: this.actualValue;
Expand Down
18 changes: 18 additions & 0 deletions projects/ngx-mask-lib/src/test/basic-logic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -928,4 +928,22 @@ describe('Directive: Mask', () => {
equal('123-4-5', '123-4-5', fixture);
equal('123-45-6', '123-45-6', fixture);
});

it('mask 00/00/0000 with keepCharacterPositions should work after setValue', () => {
const debugElement: DebugElement = fixture.debugElement.query(By.css('input'));
const inputTarget: HTMLInputElement = debugElement.nativeElement as HTMLInputElement;
spyOnProperty(document, 'activeElement').and.returnValue(inputTarget);
fixture.detectChanges();

component.mask = '00/00/0000';
component.showMaskTyped = true;
component.keepCharacterPositions = true;

equal('11/11/1111', '11/11/1111', fixture);
component.form.setValue('22/22/2222');
fixture.detectChanges();
requestAnimationFrame(() => {
expect(inputTarget.value).toBe('22/22/2222');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { IConfig } from '../../lib/ngx-mask.config';
[allowNegativeNumbers]="allowNegativeNumbers"
[leadZeroDateTime]="leadZeroDateTime"
[leadZero]="leadZero"
[keepCharacterPositions]="keepCharacterPositions"
[apm]="apm"
[validation]="validation"
[inputTransformFn]="inputTransformFn || null"
Expand Down Expand Up @@ -53,6 +54,8 @@ export class TestMaskComponent {

public specialCharacters: IConfig['specialCharacters'] | undefined;

public keepCharacterPositions: IConfig['keepCharacterPositions'] | undefined;

public showMaskTyped: IConfig['showMaskTyped'] | undefined;

public placeHolderCharacter: IConfig['placeHolderCharacter'] | undefined;
Expand Down

0 comments on commit ae0d5f8

Please sign in to comment.