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

feat: toggle transaction details #2049

Merged
merged 9 commits into from
Feb 20, 2025
Merged

Conversation

laurelfulford
Copy link
Contributor

@laurelfulford laurelfulford commented Feb 8, 2025

All Submissions:

Changes proposed in this Pull Request:

This PR makes the Transaction Details section of the Modal Checkout collapsed by default, and makes it toggle opened/closed.

I originally tried to approach this within the Newspack UI code (Automattic/newspack-plugin#3734 and Automattic/newspack-plugin#3734), but the way we destroy/re-add this table made it hard to get that approach playing nicely and not re-collapsing/requiring a bit of a rewrite.

This approach is strictly tied to the markup in the modal checkout, but let me know if the original approach would've been better!

See 1200550061930446-as-1208982074785832

How to test the changes in this Pull Request:

  1. Apply this PR and run npm run build.
  2. Under Reader Revenue settings, enable the option to cover the transaction fees, but leave it unselected by default.
  3. Run through a checkout using monthly or annual Donation product.
  4. On the second screen, confirm you see the Transaction Details heading with a chevron:

CleanShot 2025-02-07 at 17 18 31

  1. Inspect the heading (which should actually be a button) and confirm it has the attribute aria-expanded set to false, and the attribute aria-controls set to the ID that holds the transaction details table (order_review_content).
  2. Click the header and confirm that the table expands nicely.
  3. Inspect the heading and confirm the aria-expanded attribute has switched to true.

CleanShot 2025-02-10 at 12 18 47

  1. Try checking/unchecking the transaction fees checkbox, and confirm the table remains visible, and that the aria-expanded attribute on the heading stays as true.
  2. Trying clicking the 'Back' then 'Continue' button to go to the first screen of the checkout and back again, and confirm the table remains visible, and that the aria-expanded attribute remain true.
  3. Toggle the Transaction Details closed again, and repeat some of the above (toggling the transaction fees, clicking 'Back' and 'Continue) to make sure the aria-expanded attribute remains false.
  4. Run through a new checkout using the One-Time donation product.
  5. On the second screen, confirm that the Transaction Details are not visible by default.
  6. Toggle on the option to cover transaction fees, and confirm the Transaction Details heading appears.
  7. Click the Transaction Details header and confirm the table opens, and that it has the attribute aria-expanded set to true.
  8. Try toggling off and on the transaction fee coverage and confirm the section disappears, but when it reappears the table is still open and that the heading's aria-expanded attribute is still true.
  9. Trying clicking the 'Back' then 'Continue' button to go to the first screen of the checkout and back again, and confirm the table remains visible, and that the aria-expanded attribute is still true.
  10. Toggle the Transaction Details closed again, and repeat some of the above (toggling the transaction fees, clicking 'Back' and 'Continue) to make sure the aria-expanded attribute remains false.

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?

@laurelfulford
Copy link
Contributor Author

This is nearly done, I just need to make it accessible then I'll mark it ready for review!

@laurelfulford laurelfulford marked this pull request as ready for review February 10, 2025 20:21
@laurelfulford laurelfulford requested a review from a team as a code owner February 10, 2025 20:21
@laurelfulford laurelfulford requested a review from a team February 10, 2025 20:22
@laurelfulford
Copy link
Contributor Author

This should be ready to go!

@thomasguillot I've included you for a design review just to make sure things look as expected (especially with how the animation feels!).

@thomasguillot
Copy link
Contributor

I've slightly tweaked the transitions. 797c458

My main worry is how the scroll behaves. It's quite bouncy. I wonder if the user clicks this they are automatically scrolled down to the #transaction-details... Anyway it's not a blocker at all, just some I've noticed.

bouncin

@thomasguillot thomasguillot removed the request for review from a team February 11, 2025 14:03
@dkoo
Copy link
Contributor

dkoo commented Feb 11, 2025

I think the bounciness will be fixed by this PR: #2052

There's currently a resize listener on the iframe element that attempts to scroll to to the top of the content whenever the iframe resizes. I think the intention is to scroll to the top of the page when transitioning between modal checkout screens, but it ends up getting triggered by anything that could cause a resize, including things like accordions.

@laurelfulford
Copy link
Contributor Author

Thanks @thomasguillot and @dkoo!

#2052 has been merged, so I've updated this PR from trunk and it's definitely helped with the weird jerkiness -- in my testing, the modal's scroll position is staying put as you toggle open and closed the transaction details, and toggle on and off covering fees.

Copy link
Contributor

@chickenn00dle chickenn00dle left a comment

Choose a reason for hiding this comment

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

Looks good. Great work @laurelfulford!

@laurelfulford laurelfulford merged commit d254aca into trunk Feb 20, 2025
8 checks passed
@laurelfulford laurelfulford deleted the feat/toggle-transaction-details branch February 20, 2025 17:29
Copy link

Hey @laurelfulford, 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.

5 participants