fix(cvc): fall back to short "CVC" label for French locale in narrow fields - #1736
Open
AbhishekChorotiya wants to merge 1 commit into
Open
fix(cvc): fall back to short "CVC" label for French locale in narrow fields#1736AbhishekChorotiya wants to merge 1 commit into
AbhishekChorotiya wants to merge 1 commit into
Conversation
AbhishekChorotiya
requested review from
ArushKapoorJuspay,
aritro2002,
sakksham7 and
seekshiva
as code owners
August 30, 2026 20:17
AbhishekChorotiya
temporarily deployed
to
Testing
August 30, 2026 20:17 — with
GitHub Actions
Inactive
AbhishekChorotiya
had a problem deploying
to
Testing
August 30, 2026 20:18 — with
GitHub Actions
Failure
AbhishekChorotiya
had a problem deploying
to
Testing
August 30, 2026 20:18 — with
GitHub Actions
Failure
AbhishekChorotiya
had a problem deploying
to
Testing
August 30, 2026 20:18 — with
GitHub Actions
Failure
AbhishekChorotiya
had a problem deploying
to
Testing
August 30, 2026 20:18 — with
GitHub Actions
Failure
AbhishekChorotiya
had a problem deploying
to
Testing
August 30, 2026 20:18 — with
GitHub Actions
Failure
AbhishekChorotiya
temporarily deployed
to
Testing
August 30, 2026 20:23 — with
GitHub Actions
Inactive
AbhishekChorotiya
had a problem deploying
to
Testing
August 30, 2026 20:23 — with
GitHub Actions
Failure
AbhishekChorotiya
had a problem deploying
to
Testing
August 30, 2026 20:23 — with
GitHub Actions
Failure
AbhishekChorotiya
had a problem deploying
to
Testing
August 30, 2026 20:23 — with
GitHub Actions
Failure
AbhishekChorotiya
had a problem deploying
to
Testing
August 30, 2026 20:23 — with
GitHub Actions
Failure
AbhishekChorotiya
had a problem deploying
to
Testing
August 30, 2026 20:23 — with
GitHub Actions
Failure
|
[should-fix] Move the Mutating a ref during render is a React side-effect and risks stale closures or tearing in concurrent rendering. The observer callback should call the latest closure, but the ref update itself belongs inside an effect so render stays pure. |
AbhishekChorotiya
force-pushed
the
fix/cvc-label-fallback-narrow-field
branch
from
September 2, 2026 11:04
1dae4b6 to
b95f4c5
Compare
AbhishekChorotiya
temporarily deployed
to
Testing
September 2, 2026 11:04 — with
GitHub Actions
Inactive
AbhishekChorotiya
temporarily deployed
to
Testing
September 2, 2026 11:04 — with
GitHub Actions
Inactive
AbhishekChorotiya
had a problem deploying
to
Testing
September 2, 2026 11:04 — with
GitHub Actions
Failure
AbhishekChorotiya
temporarily deployed
to
Testing
September 2, 2026 11:04 — with
GitHub Actions
Inactive
AbhishekChorotiya
had a problem deploying
to
Testing
September 2, 2026 11:04 — with
GitHub Actions
Failure
AbhishekChorotiya
temporarily deployed
to
Testing
September 2, 2026 11:04 — with
GitHub Actions
Inactive
AbhishekChorotiya
temporarily deployed
to
Testing
September 2, 2026 12:15 — with
GitHub Actions
Inactive
AbhishekChorotiya
had a problem deploying
to
Testing
September 2, 2026 12:21 — with
GitHub Actions
Failure
AbhishekChorotiya
temporarily deployed
to
Testing
September 2, 2026 12:21 — with
GitHub Actions
Inactive
AbhishekChorotiya
temporarily deployed
to
Testing
September 2, 2026 12:21 — with
GitHub Actions
Inactive
AbhishekChorotiya
temporarily deployed
to
Testing
September 2, 2026 12:21 — with
GitHub Actions
Inactive
AbhishekChorotiya
had a problem deploying
to
Testing
September 2, 2026 12:21 — with
GitHub Actions
Failure
AbhishekChorotiya
force-pushed
the
fix/cvc-label-fallback-narrow-field
branch
from
September 2, 2026 12:38
f3cde5b to
df09c8e
Compare
AbhishekChorotiya
temporarily deployed
to
Testing
September 2, 2026 12:38 — with
GitHub Actions
Inactive
AbhishekChorotiya
force-pushed
the
fix/cvc-label-fallback-narrow-field
branch
from
September 2, 2026 12:43
df09c8e to
beca2a3
Compare
AbhishekChorotiya
temporarily deployed
to
Testing
September 2, 2026 12:43 — with
GitHub Actions
Inactive
AbhishekChorotiya
force-pushed
the
fix/cvc-label-fallback-narrow-field
branch
from
September 2, 2026 12:47
beca2a3 to
3d58cce
Compare
AbhishekChorotiya
temporarily deployed
to
Testing
September 2, 2026 12:48 — with
GitHub Actions
Inactive
AbhishekChorotiya
force-pushed
the
fix/cvc-label-fallback-narrow-field
branch
from
September 2, 2026 12:51
3d58cce to
cbc3e9a
Compare
AbhishekChorotiya
temporarily deployed
to
Testing
September 2, 2026 12:51 — with
GitHub Actions
Inactive
AbhishekChorotiya
force-pushed
the
fix/cvc-label-fallback-narrow-field
branch
from
September 2, 2026 12:53
cbc3e9a to
8c47b60
Compare
AbhishekChorotiya
temporarily deployed
to
Testing
September 2, 2026 12:53 — with
GitHub Actions
Inactive
The full French CVC label ("Code CVC") was getting clipped in narrow
containers. Add a French-only fallback to the short "CVC" label when the
field is too narrow, restoring the full label when it widens again.
- Scope the fallback to the French ("fr") locale only; every other locale
already ships a short CVC label, so no per-locale string/type changes are
needed.
- Add a reusable useResizeObserver hook in src/Hooks that observes the field
container, so the decision stays correct across mounts, layout changes and
resizes.
- Measure the label's natural width with canvas measureText (the floating
label is absolutely positioned and wraps, so scrollWidth cannot detect the
overflow); compare against the container width with a small buffer.
- Keep PaymentInputField generic via a new optional ~fieldContainerRef prop;
the CVC-specific logic lives in CardCVCElement.
Closes #1735
AbhishekChorotiya
force-pushed
the
fix/cvc-label-fallback-narrow-field
branch
from
September 2, 2026 12:54
8c47b60 to
9d1db0e
Compare
AbhishekChorotiya
temporarily deployed
to
Testing
September 2, 2026 12:54 — with
GitHub Actions
Inactive
AbhishekChorotiya
had a problem deploying
to
Testing
September 2, 2026 12:58 — with
GitHub Actions
Failure
AbhishekChorotiya
had a problem deploying
to
Testing
September 2, 2026 12:58 — with
GitHub Actions
Failure
AbhishekChorotiya
temporarily deployed
to
Testing
September 2, 2026 12:58 — with
GitHub Actions
Inactive
AbhishekChorotiya
temporarily deployed
to
Testing
September 2, 2026 12:58 — with
GitHub Actions
Inactive
AbhishekChorotiya
temporarily deployed
to
Testing
September 2, 2026 12:58 — with
GitHub Actions
Inactive
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.
Type of Change
Description
Closes #1735
The full French CVC label ("Code CVC") was getting clipped in narrow containers, because it is longer than the English abbreviation ("CVC"). This adds a French-only fallback: when the field is too narrow to fit "Code CVC", the widget shows the short "CVC" label instead, and restores the full label when the field is widened again.
Approach
fr) locale, because it is the only locale that ships a long CVC label — every other locale already renders a short label (e.g.fr-BEalready usesCVC). Detection islocaleString.locale == "fr", the normalized locale code from the resolved locale file, so it reliably matchesfr,fr-FR,FR, andauto→ French. No per-locale string or shared-type changes are required.useResizeObserverhook (src/Hooks/UseResizeObserver.res) observes the CVC field container, so the label choice stays correct across the element's mount, its internal layout changes, and any real container resize (and reverts to the full label when there is room again). The observer only runs whenisFrenchCvc && !isSavedCardCvcFlow. The existingResizeObservertype/binding insrc/ResizeObserver.resis reused unchanged (the hook callsResizeObserver.newResizerObserver), so its current consumers are untouched.measureTextusing the label's computed font. This is necessary because the default floating label is absolutely positioned and wraps, soscrollWidthcannot detect the horizontal overflow; it is also cheaper than DOM measurement (no reflow, no hidden node). The natural width is compared against the container'sclientWidthwith a small buffer (clientWidth - 24).PaymentInputFieldstays generic. It gains a single optional~fieldContainerRefprop and has no CVC/locale knowledge; the CVC-specific logic lives entirely inCardCVCElement.How did you test it?
Screen.Recording.2026-09-02.at.6.41.41.PM.mov
Manually verified in the demo app against a standalone
CardCVCElementrendered in a resizable container, using the local SDK build (Playwright-driven):?locale=fr, narrow field (≈52px) → label shows "CVC" and stays stable (no flicker back to "Code CVC" across the element's remount/layout transitions).?locale=fr, wide field (≈292px) → label shows "Code CVC"; shrinking it back to ≈52px → falls back to "CVC" (bidirectional).?locale=en→ unaffected (no French fallback engaged).npm run re:buildpasses.Checklist
npm run re:build