Automattic / newspack-blocks

Gutenberg blocks for the Newspack project.
207 stars 43 forks source link

fix: correct Link icon placement #1958

Closed laurelfulford closed 1 week ago

laurelfulford commented 1 week ago

All Submissions:

Changes proposed in this Pull Request:

When the Link payment option is enabled under the Stripe Gateway, the icon is placed absolutely based on the window. Unfortunately, the alignment of this button isn't always bang on -- I think (especially in the modal checkout) this is because the JavaScript adding the styles for it isn't always firing at the best time.

This PR overrides the styles and absolutely positions them inside of any Woo input element that may contain them, for greater accuracy.

This PR can be tested with https://github.com/Automattic/newspack-theme/pull/2407 to make sure the Link button doesn't disappear when you hover over it.

(When the Link icon appears in the input, it doesn't do anything on click; this will be handled separately!)

How to test the changes in this Pull Request:

  1. Under WooCommerce > Payments > Stripe, enable the new non-legacy checkout experience, and enable Link as an express payment option:

CleanShot 2024-11-14 at 11 27 52

  1. Run a checkout using the modal checkout, and note the appearance of the Link button in the Email field. Sometimes it's just slightly offset in the input; other times (like for me if you hit Continue and Back), it will be super mis-aligned. You can also try submitting the form without filling anything out -- the shift from the error messages will also break the placement:

image

  1. Apply this PR and run npm run build.
  2. Repeat step 2 a couple times, including clicking Continue and Back a few times, and confirm the button is always placed inside of the input:

CleanShot 2024-11-14 at 11 33 49

Other information:

laurelfulford commented 1 week ago

🥳