From 18bb6603a4a8332a2f59501ea6bd9f18c7df9e0a Mon Sep 17 00:00:00 2001 From: fabcall <43019077+fabcall@users.noreply.github.com> Date: Fri, 22 Jan 2021 00:02:41 -0300 Subject: [PATCH] Update formatters.ts Replace the length implementation since the user could be copy / pasting a shorter value (which should be formatted as well). --- utils/formatters.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/formatters.ts b/utils/formatters.ts index 2d7542a..fe249b4 100644 --- a/utils/formatters.ts +++ b/utils/formatters.ts @@ -3,7 +3,7 @@ export function cardNumberFormatter( newValue: string, ): string { // user is deleting so return without formatting - if (oldValue.length > newValue.length) { + if (oldValue === newValue.slice(0, -1)) { return newValue } @@ -18,7 +18,7 @@ export function expirationDateFormatter( newValue: string, ): string { // user is deleting so return without formatting - if (oldValue.length > newValue.length) { + if (oldValue === newValue.slice(0, -1)) { return newValue }