Skip to content

Commit

Permalink
fix(ref: no-ref): fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
andriikamaldinov1 committed Dec 20, 2024
1 parent 9ae4102 commit 812b68c
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 10 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# 19.0.5(2024-12-17)
# 19.0.6(2024-12-20)

### Fix

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


# 19.0.5(2024-12-20)

### Fix

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

# 19.0.4(2024-12-13)
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": "19.0.5",
"version": "19.0.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": "19.0.5",
"version": "19.0.6",
"description": "awesome ngx mask",
"keywords": [
"ng2-mask",
Expand Down
19 changes: 12 additions & 7 deletions projects/ngx-mask-lib/src/lib/ngx-mask-applier.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,18 @@ export class NgxMaskApplierService {
let decimalMarker = this.decimalMarker;

if (Array.isArray(this.decimalMarker)) {
const marker = this.decimalMarker.find((dm) => dm !== this.thousandSeparator);

decimalMarker = marker
? marker
: this.actualValue.includes(this.decimalMarker[0])
? this.decimalMarker[0]
: this.decimalMarker[1];
if (
this.actualValue.includes(this.decimalMarker[0]) ||
this.actualValue.includes(this.decimalMarker[1])
) {
decimalMarker = this.actualValue.includes(this.decimalMarker[0])
? this.decimalMarker[0]
: this.decimalMarker[1];
} else {
decimalMarker = this.decimalMarker.find(
(dm) => dm !== this.thousandSeparator
) as '.' | ',';
}
}

if (backspaced) {
Expand Down
79 changes: 79 additions & 0 deletions projects/ngx-mask-lib/src/test/separator.cy-spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CypressTestMaskComponent } from './utils/cypress-test-component.component';
import { signal } from '@angular/core';
import type { NgxMaskConfig } from 'ngx-mask';

describe('Test Date Hh:m0', () => {
it('Mask separator.2 check cursor with value 100.0', () => {
Expand Down Expand Up @@ -506,4 +507,82 @@ describe('Test Date Hh:m0', () => {
.type('{backspace}')
.should('have.value', '0.05');
});

it('should correct work after backspace separator.2 with default values', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: signal('separator.2'),
decimalMarker: signal(['.', ','] as NgxMaskConfig['decimalMarker']),
thousandSeparator: signal(' '),
},
});

cy.get('#masked')
.type('1000000,35')
.should('have.value', '1 000 000,35')
.type('{leftArrow}'.repeat(11))
.type('{backspace}')
.should('have.value', '0,35');

cy.get('#masked').clear();

cy.get('#masked')
.type('1000000.35')
.should('have.value', '1 000 000.35')
.type('{leftArrow}'.repeat(11))
.type('{backspace}')
.should('have.value', '0.35');
});

it('should correct work after backspace separator.2 with default values', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: signal('separator.2'),
decimalMarker: signal(['.', ','] as NgxMaskConfig['decimalMarker']),
thousandSeparator: signal(' '),
},
});

cy.get('#masked')
.type('60,35')
.should('have.value', '60,35')
.type('{leftArrow}'.repeat(4))
.type('{backspace}')
.should('have.value', '0,35');

cy.get('#masked').clear();

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

it('should correct work after backspace separator.2 with default values', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: signal('separator.2'),
decimalMarker: signal(['.', ','] as NgxMaskConfig['decimalMarker']),
thousandSeparator: signal(' '),
},
});

cy.get('#masked')
.type('200,35')
.should('have.value', '200,35')
.type('{leftArrow}'.repeat(5))
.type('{backspace}')
.should('have.value', '0,35');

cy.get('#masked').clear();

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

0 comments on commit 812b68c

Please sign in to comment.