Skip to content

Hotfix/firefox cvc#1

Merged
raphaeldieu merged 2 commits into
masterfrom
hotfix/firefox-cvc
Jun 25, 2018
Merged

Hotfix/firefox cvc#1
raphaeldieu merged 2 commits into
masterfrom
hotfix/firefox-cvc

Conversation

@andyhsh

@andyhsh andyhsh commented Jun 14, 2018

Copy link
Copy Markdown
  • Fix CVC input field when user has typed in 4 digits fore Firefox

Reference: laurihy#97

Comment thread lib/angular-payments.js
if (!/^\d+$/.test(digit) && !e.meta && e.keyCode >= 46) {

// Allows backspace, delete and arrow keys when input length is 4 and the browser is Firefox
if (e.keyCode == 46 || e.keyCode == 8||(e.keyCode >=37 && e.keyCode <=40)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do you know that it is Firefox here?

@andyhsh andyhsh Jun 19, 2018

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raphaeldieu IE / Chrome / Safari detects the "keypress" event only when an actual character input is added. Since backspace and arrow keys don't add a new character, the function doesn't run.

For Firefox, the "keypress" event is run even on backspace / arrow keys and so with the old code when val.length is more than 4, it will always fall down to the else block which has a e.preventDefault() preventing the user from any form of input. The new code which detects arrow / delete / backspace keys therefore can only occur on firefox

Comment thread lib/angular-payments.js
}
}]);angular.module('angularPayments')
}])
;angular.module('angularPayments')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ran grunt and I guess it changed the line. Didn't directly edit anything inside the /lib folder

@raphaeldieu raphaeldieu merged commit c5496ea into master Jun 25, 2018
@raphaeldieu raphaeldieu deleted the hotfix/firefox-cvc branch June 25, 2018 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants