Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ref: no-ref): fix issues #1484

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
});
Loading