Skip to content

fix: add rtl layout support to card form fields in dc#269

Open
jakubjasinsky wants to merge 1 commit into
masterfrom
jakub-dynamic-checkout-rtl
Open

fix: add rtl layout support to card form fields in dc#269
jakubjasinsky wants to merge 1 commit into
masterfrom
jakub-dynamic-checkout-rtl

Conversation

@jakubjasinsky

@jakubjasinsky jakubjasinsky commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

Arabic (RTL) locale in Dynamic Checkout rendered the card form inputs with left-aligned, LTR placeholders. The card number, expiry, and CVC fields are hosted iframes, so the widget's dir="rtl" never reached them.

Changes

  • Pass direction: "rtl" to the hosted card fields' style options for RTL locales — the field applies text-align: right (and true RTL only for CVC), so card number digits keep their order
  • Add Translations.isRtlLocale() and reuse it for the existing dir="rtl" wrapper check instead of a hardcoded "ar" comparison
  • Fix RTL CVC input padding: restore the base 8px on the text side (was 0, leaving the placeholder flush against the input edge)

Additional Context

  • Moving the in-iframe scheme selection logo to the left in RTL requires a checkout-cdn change (body.rtl handling in ccfield.html/Field.ts), shipped separately

Copilot AI review requested due to automatic review settings July 13, 2026 08:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds right-to-left (RTL) layout support for Dynamic Checkout’s card form by enabling RTL direction on the widget wrapper and hosted card field iframes, plus a small RTL styling tweak.

Changes:

  • Introduces Translations.isRtlLocale() and centralizes RTL locale detection.
  • Applies dir="rtl" to the widget wrapper and passes direction: "rtl" to hosted card field iframe styles.
  • Adjusts RTL CVC input padding and bumps package version.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/dynamic-checkout/utils/translations.ts Adds RTL locale detection helper used by the widget and card fields.
src/dynamic-checkout/styles/default.ts Tweaks RTL padding for the card CVC input.
src/dynamic-checkout/payment-methods/card.ts Passes RTL direction into hosted card field iframe styles when locale is RTL.
src/dynamic-checkout/dynamic-checkout.ts Sets dir="rtl" on the widget wrapper when locale is RTL.
package.json Bumps library version to 1.9.8.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 24 to +33
static getText(key: string, locale: string) {
const keys =
Translations.localeTranslationsMap[locale] || Translations.localeTranslationsMap.en

return keys[key] || ""
}

static isRtlLocale(locale: string) {
return Translations.rtlLocales.indexOf(locale) !== -1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants