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

Enable scrolling in card present modals when it cannot grow in size anymore #15328

Merged
merged 6 commits into from
Mar 12, 2025

Conversation

staskus
Copy link
Contributor

@staskus staskus commented Mar 12, 2025

Closes: #15321

Description

CardPresentPaymentsModalViewController used for all the modals during the card reader connection and payment process may cut some content if it doesn't fit anymore.

CardPresentPaymentsModalViewController already has dynamic abilities, since it grows from minimum to maximum size while the content is growing. However, if modals contain a lot of elements with larger dynamic type sizes, then some content may be cut.

Solution

Wrap modal content in the UISCrollView. I had to play around with constraints and priorities to make sure scrolling only kicked in once the modal could not grow in size anymore.

Due to the addition of scroll view, I removed limits of how long the text can be, so it wouldn't be cut or shrunk when dynamic type size grows.

Additionally, there were issues with button content not fitting. I couldn't quickly figure out why buttons cannot go into multiline so decided to reduce minimumScaleFactor. This is not a perfect solution but I don't notice issues with button text being cut-off anymore.

Possible improvements

There could be more improvements to this solution. For example, growing modal in width, especially on iPad, once a certain accessibility size is reached. We could also put a button container in a separate scroll view. It looks like this is what native iOS alerts do, so both some actions and some content are always visible.

Steps to reproduce

  1. Set location permission of Woo app to Ask next time
  2. Create an order and start pthe ayment process
  3. Increase/decrease dynamic type size and confirm different modals grow in size and enable scrolling once the content doesn't fit anymore

Testing information

The constraints differ depending on the size class, so I performed testing both at Storyboard level, iPhone 14 Pro 17.7 device, iPad Air M2 18.3 device, and simulator to make sure the changes in layout didn't break anything.

Screenshots

iPad Device

iPad.-.Card.Present.Modal.Self.Sizing.Scroll.View.MP4

iPhone Device

iPhone.-.Card.Present.Payment.Scrolling.View.mov

iPad Simulator

iPad.-.Dynamic.Type.Size.mp4

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on all devices (phone/tablet) and no regressions are added.

staskus added 5 commits March 12, 2025 10:13
The modal continues to behave as before - grows in size if content expands but when the content doesn't fit anymore the modal starts support scrolling.

In 99% of cases it only kicks in with larger dynamic type size
Only applies to large accessibility sizes and long button titles
Modals now support scrolling so longer content can be shown without cutting it off or shrinking it
@staskus staskus added type: bug A confirmed bug. category: accessibility Related to accessibility. feature: mobile payments Related to mobile payments / card present payments / Woo Payments. labels Mar 12, 2025
@staskus staskus added this to the 22.0 milestone Mar 12, 2025
@staskus staskus requested a review from joshheald March 12, 2025 08:23
Copy link

coderabbitai bot commented Mar 12, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

This pull request updates the font styling for email address text in two view model classes by replacing a fixed bold system font with a dynamic preferred font for body text. Additionally, it adjusts UI properties in a modal view controller and its associated XIB file—setting labels to allow unlimited lines, reducing button title scale factors, and restructuring the layout from a vertical stack view to a scroll view with updated constraints and outlet references.

Changes

File(s) Change Summary
WooCommerce/.../CardPresentModalBuiltInSuccessEmailSent.swift
WooCommerce/.../CardPresentModalSuccessEmailSent.swift
Updated the font attribute for email addresses by replacing UIFont.boldSystemFont(ofSize: UIFont.systemFontSize) with UIFont.preferredFont(forTextStyle: .body).bold to support dynamic text sizing.
WooCommerce/.../CardPresentPaymentsModalViewController.swift Modified UI element properties: set label numberOfLines to 0 (unlimited) and adjusted button minimumScaleFactor from 0.5 to 0.3 to enhance text display.
WooCommerce/.../CardPresentPaymentsModalViewController.xib Replaced a vertical stack view with a scroll view and restructured content under a new container view. Updated constraints and the bottomPaddingRegular outlet to accommodate the revised layout.

Possibly related PRs

Suggested labels

type: task

Suggested reviewers

  • joshheald

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@staskus
Copy link
Contributor Author

staskus commented Mar 12, 2025

@coderabbitai review

Copy link

coderabbitai bot commented Mar 12, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@wpmobilebot
Copy link
Collaborator

WooCommerce iOS📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS WooCommerce iOS
Build Numberpr15328-38d1c30
Version21.9
Bundle IDcom.automattic.alpha.woocommerce
Commit38d1c30
App Center BuildWooCommerce - Prototype Builds #13291
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

Copy link
Contributor

@joshheald joshheald left a comment

Choose a reason for hiding this comment

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

Thanks for improving this! Works well.

@staskus staskus merged commit 9a52eb2 into trunk Mar 12, 2025
15 checks passed
@staskus staskus deleted the fix/15321-card-present-modals-dynamic-type branch March 12, 2025 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: accessibility Related to accessibility. feature: mobile payments Related to mobile payments / card present payments / Woo Payments. type: bug A confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Mobile Payments] Card Present Payment modals are not adapting well to large accessibility sizes
3 participants