From 1381c5d36ccb8ca85f3016f8b99a449030644b4e Mon Sep 17 00:00:00 2001 From: Thomas Roberts Date: Tue, 31 Jan 2023 17:11:19 +0000 Subject: [PATCH 1/5] Prevent coupon error disappearing on blur if value unchanged --- .../checkout/components/text-input/validated-text-input.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/checkout/components/text-input/validated-text-input.tsx b/packages/checkout/components/text-input/validated-text-input.tsx index fb79925bd70..fc8f836a7b1 100644 --- a/packages/checkout/components/text-input/validated-text-input.tsx +++ b/packages/checkout/components/text-input/validated-text-input.tsx @@ -101,6 +101,10 @@ const ValidatedTextInput = ( { inputObject.value = inputObject.value.trim(); inputObject.setCustomValidity( '' ); + if ( previousValue === inputObject.value ) { + return; + } + const inputIsValid = customValidation ? inputObject.checkValidity() && customValidation( inputObject ) : inputObject.checkValidity(); @@ -120,6 +124,7 @@ const ValidatedTextInput = ( { } ); }, [ + previousValue, clearValidationError, customValidation, errorIdString, From ca8c385a83831273aea1e8d4ae43eb7cb7e46576 Mon Sep 17 00:00:00 2001 From: Thomas Roberts Date: Tue, 31 Jan 2023 17:11:32 +0000 Subject: [PATCH 2/5] Check for inline selector on coupon error --- tests/e2e/specs/shopper/cart-checkout/checkout.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/specs/shopper/cart-checkout/checkout.test.js b/tests/e2e/specs/shopper/cart-checkout/checkout.test.js index 4aa7a161e85..3656c4235a2 100644 --- a/tests/e2e/specs/shopper/cart-checkout/checkout.test.js +++ b/tests/e2e/specs/shopper/cart-checkout/checkout.test.js @@ -304,7 +304,7 @@ describe( 'Shopper → Checkout', () => { await shopper.block.goToCheckout(); await shopper.block.applyCouponFromCheckout( coupon.code ); await page.waitForSelector( - '.wc-block-components-notices__notice' + '.wc-block-components-totals-coupon__form .wc-block-components-validation-error' ); await expect( page ).toMatch( 'Coupon usage limit has been reached.' From f21924daae36745f416beaf80048394090affdd9 Mon Sep 17 00:00:00 2001 From: Thomas Roberts Date: Tue, 31 Jan 2023 17:11:19 +0000 Subject: [PATCH 3/5] Prevent coupon error disappearing on blur if value unchanged From 35c2fd83d5add8d341134a59690f65ea5d028478 Mon Sep 17 00:00:00 2001 From: Thomas Roberts Date: Tue, 31 Jan 2023 17:11:32 +0000 Subject: [PATCH 4/5] Check for inline selector on coupon error From d44bf84aa36ad5609a90e33e035958edde642bec Mon Sep 17 00:00:00 2001 From: Thomas Roberts Date: Tue, 31 Jan 2023 17:42:42 +0000 Subject: [PATCH 5/5] Update selector for coupon E2E test --- tests/e2e/specs/shopper/cart-checkout/checkout.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/specs/shopper/cart-checkout/checkout.test.js b/tests/e2e/specs/shopper/cart-checkout/checkout.test.js index 3656c4235a2..11e3d50f9bb 100644 --- a/tests/e2e/specs/shopper/cart-checkout/checkout.test.js +++ b/tests/e2e/specs/shopper/cart-checkout/checkout.test.js @@ -304,7 +304,7 @@ describe( 'Shopper → Checkout', () => { await shopper.block.goToCheckout(); await shopper.block.applyCouponFromCheckout( coupon.code ); await page.waitForSelector( - '.wc-block-components-totals-coupon__form .wc-block-components-validation-error' + '.wc-block-components-totals-coupon__content .wc-block-components-validation-error' ); await expect( page ).toMatch( 'Coupon usage limit has been reached.'