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 Nov 1, 2024
1 parent 2d84139 commit 827ebdc
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 243 deletions.
15 changes: 10 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
https://github.com/JsDaddy/ngx-mask/issues/1427
https://github.com/JsDaddy/ngx-mask/issues/1405
https://github.com/JsDaddy/ngx-mask/issues/1426
https://github.com/JsDaddy/ngx-mask/issues/1406
https://github.com/JsDaddy/ngx-mask/issues/1420
# 18.0.2(2024-11-01)

### Fix

- Fix ([#1427](https://github.com/JsDaddy/ngx-mask/issues/1427))
- Fix ([#1405](https://github.com/JsDaddy/ngx-mask/issues/1405))
- Fix ([#1426](https://github.com/JsDaddy/ngx-mask/issues/1426))
- Fix ([#1406](https://github.com/JsDaddy/ngx-mask/issues/1406))
- Fix ([#1420](https://github.com/JsDaddy/ngx-mask/issues/1420))
- Fix ([#1416](https://github.com/JsDaddy/ngx-mask/issues/1416))

# 18.0.1(2024-10-29)

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": "18.0.1",
"version": "18.0.2",
"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": "18.0.1",
"version": "18.0.2",
"description": "awesome ngx mask",
"keywords": [
"ng2-mask",
Expand Down
1 change: 0 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 @@ -413,7 +413,6 @@ export class NgxMaskApplierService {
) &&
shiftStep <= 0)
) {
console.log('@@@@@@@@@@@222222');
this._shift.clear();
backspaceShift = true;
shift = shiftStep;
Expand Down
9 changes: 8 additions & 1 deletion projects/ngx-mask-lib/src/lib/ngx-mask.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,14 @@ export class NgxMaskDirective implements ControlValueAccessor, OnChanges, Valida
((el.selectionStart as number) || (el.selectionEnd as number)) <=
this._maskService.prefix.length
) {
el.selectionStart = this._maskService.prefix.length;
const specialCharactersAtTheStart =
this._maskService.maskExpression.match(
new RegExp(
`^[${this._maskService.specialCharacters.map((c) => `\\${c}`).join('')}]+`
)
)?.[0].length || 0;

el.selectionStart = this._maskService.prefix.length + specialCharactersAtTheStart;
return;
}
/** select only inserted text */
Expand Down
40 changes: 40 additions & 0 deletions projects/ngx-mask-lib/src/test/show-mask-typed.cy-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { CypressTestMaskComponent } from './utils/cypress-test-component.component';
import { CypressTestMaskModule } from './utils/cypress-test.module';

describe('Directive: Mask (Delete)', () => {
it('should place cursor in right place mask (000) 000-0000', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: '(000) 000-0000',
showMaskTyped: true,
},
imports: [CypressTestMaskModule],
});

cy.get('#masked').click().should('have.prop', 'selectionStart', 1);
});

it('should place cursor in right place mask ((000)) 000-0000', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: '((000)) 000-0000',
showMaskTyped: true,
},
imports: [CypressTestMaskModule],
});

cy.get('#masked').click().should('have.prop', 'selectionStart', 2);
});

it('should place cursor in right place mask 000 000-0000', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: '000 000-0000',
showMaskTyped: true,
},
imports: [CypressTestMaskModule],
});

cy.get('#masked').click().should('have.prop', 'selectionStart', 0);
});
});
Loading

0 comments on commit 827ebdc

Please sign in to comment.