Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(modal-checkout): better iframe sizing #2052

Merged
merged 1 commit into from
Feb 13, 2025
Merged

Conversation

dkoo
Copy link
Contributor

@dkoo dkoo commented Feb 11, 2025

All Submissions:

Changes proposed in this Pull Request:

Improves the sizing of the modal checkout iframe and its content wrapper element to allow fixed-position elements and scrollTo methods to work inside the iframe content.

The max-height of a Newspack UI modal element is 90% of its fixed full-viewport parent element, effectively 90vh or 90% of the total viewport height. The height of the iframe should not exceed this height, minus the height of the modal's header element, if present, to allow for proper content scrolling and positioning behavior inside the iframe's content window.

See also: Automattic/newspack-plugin#3741

How to test the changes in this Pull Request:

  1. On trunk, connect reCAPTCHA v2 and set up a shippable product that can be purchased via Checkout Button.
  2. As a reader, start a modal checkout transaction for the shippable product.
  3. Observe the following behavior:
  • When checking or unchecking the "Ship to a different address?" checkbox, the modal will scroll near (but not all the way to) the top of the iframe content window
  • When rendering the reCAPTCHA v2 widget upon clicking "Complete transaction", the widget appears at the top of the page, and the modal will scroll near (but not all the way to) the top of the iframe content window, to bring it into view
  1. Check out this branch and fix(recaptcha): no need to scroll to top when showing v2 widget newspack-plugin#3741.
  2. Refresh your site and start a new modal checkout transaction again. This time confirm the following behavior:
  • When checking or unchecking the "Ship to a different address?" checkbox, the modal will NOT scroll away from the checkbox
  • When transitioning between screens of the modal checkout form, the modal checkout WILL scroll all the way to the top of the iframe content window
  • When rendering the reCAPTCHA v2 widget upon clicking "Complete transaction", the widget appears directly over the button, and the modal will NOT scroll away from the "Complete transaction" button
  • After completing the transaction, the modal will still properly resize to contain the success message

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Copy link
Contributor

@laurelfulford laurelfulford left a comment

Choose a reason for hiding this comment

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

This looks really nice, @dkoo! It works as described, and also fixes the weird 'hop up' that happens on when you toggle on and off the option to cover the transaction fees when the Transaction Details table is already visible (like for monthly donations) 🎉

@dkoo dkoo merged commit aa308f2 into trunk Feb 13, 2025
9 checks passed
@dkoo dkoo deleted the fix/modal-iframe-sizing branch February 13, 2025 00:11
Copy link

Hey @dkoo, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label.

If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label.

Thank you! ❤️

matticbot pushed a commit that referenced this pull request Feb 20, 2025
# [4.7.0-alpha.1](v4.6.0...v4.7.0-alpha.1) (2025-02-20)

### Bug Fixes

* **carousel:** avoid editor crash on empty ([#2058](#2058)) ([c316801](c316801))
* **modal-checkout:** better iframe sizing ([#2052](#2052)) ([aa308f2](aa308f2))
* **recaptcha:** use clone of #place_order button to trigger checkout ([#2028](#2028)) ([46eb8b5](46eb8b5)), closes [#2030](#2030) [#2030](#2030)

### Features

* add styles to fix Braintree modal appearance ([#2036](#2036)) ([9ab2c62](9ab2c62))
* add toggle for transaction details ([#2049](#2049)) ([d254aca](d254aca))
* **carousel:** rename block and reorganise settings ([#1962](#1962)) ([9905717](9905717))
* update blocks with new brand ([#2050](#2050)) ([2711302](2711302))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 4.7.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants