fix: add rtl layout support to card form fields in dc#269
Open
jakubjasinsky wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
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 passesdirection: "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 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
direction: "rtl"to the hosted card fields' style options for RTL locales — the field appliestext-align: right(and true RTL only for CVC), so card number digits keep their orderTranslations.isRtlLocale()and reuse it for the existingdir="rtl"wrapper check instead of a hardcoded"ar"comparisonAdditional Context
checkout-cdnchange (body.rtlhandling inccfield.html/Field.ts), shipped separately