Skip to content

Commit c44a5ed

Browse files
feat(ref: no-ref): release
feat(ref: no-ref): release
2 parents 75a506a + 9c2a8a1 commit c44a5ed

File tree

5 files changed

+100
-10
lines changed

5 files changed

+100
-10
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
# 19.0.5(2024-12-17)
1+
# 19.0.6(2024-12-20)
22

33
### Fix
44

55
- Fix ([#1481](https://github.com/JsDaddy/ngx-mask/issues/1481))
6+
7+
8+
# 19.0.5(2024-12-20)
9+
10+
### Fix
11+
612
- Fix ([#1411](https://github.com/JsDaddy/ngx-mask/issues/1411))
713

814
# 19.0.4(2024-12-13)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngx-mask",
3-
"version": "19.0.5",
3+
"version": "19.0.6",
44
"description": "Awesome ngx mask",
55
"license": "MIT",
66
"engines": {

projects/ngx-mask-lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngx-mask",
3-
"version": "19.0.5",
3+
"version": "19.0.6",
44
"description": "awesome ngx mask",
55
"keywords": [
66
"ng2-mask",

projects/ngx-mask-lib/src/lib/ngx-mask-applier.service.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,18 @@ export class NgxMaskApplierService {
200200
let decimalMarker = this.decimalMarker;
201201

202202
if (Array.isArray(this.decimalMarker)) {
203-
const marker = this.decimalMarker.find((dm) => dm !== this.thousandSeparator);
204-
205-
decimalMarker = marker
206-
? marker
207-
: this.actualValue.includes(this.decimalMarker[0])
208-
? this.decimalMarker[0]
209-
: this.decimalMarker[1];
203+
if (
204+
this.actualValue.includes(this.decimalMarker[0]) ||
205+
this.actualValue.includes(this.decimalMarker[1])
206+
) {
207+
decimalMarker = this.actualValue.includes(this.decimalMarker[0])
208+
? this.decimalMarker[0]
209+
: this.decimalMarker[1];
210+
} else {
211+
decimalMarker = this.decimalMarker.find(
212+
(dm) => dm !== this.thousandSeparator
213+
) as '.' | ',';
214+
}
210215
}
211216

212217
if (backspaced) {

projects/ngx-mask-lib/src/test/separator.cy-spec.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { CypressTestMaskComponent } from './utils/cypress-test-component.component';
22
import { signal } from '@angular/core';
3+
import type { NgxMaskConfig } from 'ngx-mask';
34

45
describe('Test Date Hh:m0', () => {
56
it('Mask separator.2 check cursor with value 100.0', () => {
@@ -506,4 +507,82 @@ describe('Test Date Hh:m0', () => {
506507
.type('{backspace}')
507508
.should('have.value', '0.05');
508509
});
510+
511+
it('should correct work after backspace separator.2 with default values', () => {
512+
cy.mount(CypressTestMaskComponent, {
513+
componentProperties: {
514+
mask: signal('separator.2'),
515+
decimalMarker: signal(['.', ','] as NgxMaskConfig['decimalMarker']),
516+
thousandSeparator: signal(' '),
517+
},
518+
});
519+
520+
cy.get('#masked')
521+
.type('1000000,35')
522+
.should('have.value', '1 000 000,35')
523+
.type('{leftArrow}'.repeat(11))
524+
.type('{backspace}')
525+
.should('have.value', '0,35');
526+
527+
cy.get('#masked').clear();
528+
529+
cy.get('#masked')
530+
.type('1000000.35')
531+
.should('have.value', '1 000 000.35')
532+
.type('{leftArrow}'.repeat(11))
533+
.type('{backspace}')
534+
.should('have.value', '0.35');
535+
});
536+
537+
it('should correct work after backspace separator.2 with default values', () => {
538+
cy.mount(CypressTestMaskComponent, {
539+
componentProperties: {
540+
mask: signal('separator.2'),
541+
decimalMarker: signal(['.', ','] as NgxMaskConfig['decimalMarker']),
542+
thousandSeparator: signal(' '),
543+
},
544+
});
545+
546+
cy.get('#masked')
547+
.type('60,35')
548+
.should('have.value', '60,35')
549+
.type('{leftArrow}'.repeat(4))
550+
.type('{backspace}')
551+
.should('have.value', '0,35');
552+
553+
cy.get('#masked').clear();
554+
555+
cy.get('#masked')
556+
.type('60.35')
557+
.should('have.value', '60.35')
558+
.type('{leftArrow}'.repeat(4))
559+
.type('{backspace}')
560+
.should('have.value', '0.35');
561+
});
562+
563+
it('should correct work after backspace separator.2 with default values', () => {
564+
cy.mount(CypressTestMaskComponent, {
565+
componentProperties: {
566+
mask: signal('separator.2'),
567+
decimalMarker: signal(['.', ','] as NgxMaskConfig['decimalMarker']),
568+
thousandSeparator: signal(' '),
569+
},
570+
});
571+
572+
cy.get('#masked')
573+
.type('200,35')
574+
.should('have.value', '200,35')
575+
.type('{leftArrow}'.repeat(5))
576+
.type('{backspace}')
577+
.should('have.value', '0,35');
578+
579+
cy.get('#masked').clear();
580+
581+
cy.get('#masked')
582+
.type('200.35')
583+
.should('have.value', '200.35')
584+
.type('{leftArrow}'.repeat(5))
585+
.type('{backspace}')
586+
.should('have.value', '0.35');
587+
});
509588
});

0 commit comments

Comments
 (0)