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 1676be0 commit d4006f8
Show file tree
Hide file tree
Showing 5 changed files with 62 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.5(2024-07-16)

### Fix

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

# 17.1.4(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.4",
"version": "17.1.5",
"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.4",
"version": "17.1.5",
"description": "awesome ngx mask",
"keywords": [
"ng2-mask",
Expand Down
4 changes: 3 additions & 1 deletion projects/ngx-mask-lib/src/lib/ngx-mask-applier.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ export class NgxMaskApplierService {
inputValue[position] === decimalMarker;
const zeroIndexNumberZero = inputValue[0] === MaskExpression.NUMBER_ZERO;
const zeroIndexMinus = inputValue[0] === MaskExpression.MINUS;
const zeroIndexThousand = inputValue[0] === this.thousandSeparator;
const firstIndexDecimalMarker = inputValue[1] === decimalMarker;
const firstIndexNumberZero = inputValue[1] === MaskExpression.NUMBER_ZERO;
const secondIndexDecimalMarker = inputValue[2] === decimalMarker;
Expand All @@ -298,9 +299,10 @@ export class NgxMaskApplierService {
// eslint-disable-next-line no-param-reassign
inputValue = MaskExpression.MINUS + inputValueAfterZero;
}

if (
inputValueAfterZero !== MaskExpression.MINUS &&
((position === 0 && !zeroIndexNumberZero) ||
((position === 0 && (zeroIndexNumberZero || zeroIndexThousand)) ||
(this.allowNegativeNumbers &&
position === 1 &&
zeroIndexMinus &&
Expand Down
51 changes: 51 additions & 0 deletions projects/ngx-mask-lib/src/test/delete.cy-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,4 +551,55 @@ describe('Directive: Mask (Delete)', () => {
.type('{backspace}')
.should('have.value', '-33');
});

it('should correct work after backspace separator.2 when first digit .', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
thousandSeparator: '.',
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('50004')
.should('have.value', '50.004')
.type('{leftArrow}'.repeat(5))
.type('{backspace}')
.should('have.value', '4');
});

it('should correct work after backspace separator.2 when first digit ,', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
thousandSeparator: ',',
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('50004')
.should('have.value', '50,004')
.type('{leftArrow}'.repeat(5))
.type('{backspace}')
.should('have.value', '4');
});

it('should correct work after backspace separator.2 when first digit whitespace', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
thousandSeparator: ' ',
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('50004')
.should('have.value', '50 004')
.type('{leftArrow}'.repeat(5))
.type('{backspace}')
.should('have.value', '4');
});
});

0 comments on commit d4006f8

Please sign in to comment.