diff --git a/cypress/e2e/v4.x.x/set-mask.cy.ts b/cypress/e2e/v4.x.x/set-mask.cy.ts index d7abe4c..894d9a1 100644 --- a/cypress/e2e/v4.x.x/set-mask.cy.ts +++ b/cypress/e2e/v4.x.x/set-mask.cy.ts @@ -88,6 +88,35 @@ describe( } ); + describe( + 'form submit', + () => { + beforeEach( + () => { + cy.visit(getUrl({ prefix: '$', suffix: 'CAD' }, '6.66')); + } + ); + + it( + 'should trigger form submit', + (done) => { + const spy = cy.spy().as('submit'); + + cy.get('form').then(form$ => { + form$.on('submit', e => { + e.preventDefault(); + spy(); + done(); + }); + }); + + cy.get('input').type('{Enter}'); + + cy.get('@submit').should('have.not.been.called'); + }, + ); + } + ); } ); @@ -307,7 +336,6 @@ describe( } ); - describe( 'negative numbers', () => { diff --git a/package-lock.json b/package-lock.json index 61d93f0..6bfd0a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "simple-mask-money", - "version": "4.1.1", + "version": "4.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "simple-mask-money", - "version": "4.1.1", + "version": "4.1.2", "hasInstallScript": true, "license": "Apache-2.0", "devDependencies": { diff --git a/package.json b/package.json index ad09588..279c1a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "simple-mask-money", - "version": "4.1.1", + "version": "4.1.2", "private": false, "description": "Simple money mask developed with pure JavaScript. To run on Client Side and Server Side", "types": "./lib/simple-mask-money.d.ts", diff --git a/src/set-mask.ts b/src/set-mask.ts index 8042bba..37c62ee 100644 --- a/src/set-mask.ts +++ b/src/set-mask.ts @@ -223,6 +223,9 @@ function setMask( let start = element.selectionStart ?? lastPositionToNumber; let end = element.selectionEnd ?? lastPositionToNumber; + // Trigger input submit + if (e.key === 'Enter') return; + // Select all if (e.ctrlKey && e.key === 'a') return setCaretPosition([firstPositionToNumber, lastPositionToNumber]);