Skip to content

RTL: right-align number next to the flag/dial-code button (pure-CSS layout)#1

Open
johnnyshields wants to merge 1 commit into
rtl-logical-propertiesfrom
rtl-dial-code-prefix
Open

RTL: right-align number next to the flag/dial-code button (pure-CSS layout)#1
johnnyshields wants to merge 1 commit into
rtl-logical-propertiesfrom
rtl-dial-code-prefix

Conversation

@johnnyshields

@johnnyshields johnnyshields commented Jul 5, 2026

Copy link
Copy Markdown

Summary

Builds on the logical-properties RTL work (rtl-logical-properties, PR jackocnr#2181) with an opinionated RTL layout for TableCheck: the phone number is right-aligned so it sits next to the country button, and the number, the separate dial code and the flag read as one group hugging the flag — e.g. 51 234 5678 +966 🇸🇦 — inside a full-width field.

[            51 234 5678  +966  ⌄ 🇸🇦 ]      (RTL)

This is a TableCheck-specific layout preference, kept as a separate PR so jackocnr#2181 stays the minimal, upstreamable logical-properties fix.

No direction detection in JS · one dial-code position · pure-CSS layout

  • ui.ts — no getComputedStyle/direction checks. The separate dial code keeps one position (inside the country button, the upstream default) that serves both LTR and RTL.
  • Layout is pure CSS, scoped to :dir(rtl): right-align the number and put the flag-clearance on the input's physical inline-end.
  • The one JS touch is a measurement, not layout/direction logic. Browsers resolve a tel input's own direction as LTR even inside an RTL page, so ui.ts's existing flag-clearance padding-inline-start lands on the physical LEFT — the wrong side when the country button is on the right. ui.ts now also publishes that already-measured button width as the --iti-country-clearance custom property; the :dir(rtl) rule neutralises the left padding and re-applies the clearance on the right. The direction/side decision is 100% in CSS — JS only reports a width (exactly as upstream already does for padding-inline-start).

The :dir(rtl) scope is keyed off the wrapper's directionality (a plain <div>, whose :dir resolves reliably), so it doesn't depend on the <input>'s own (LTR) :dir.

Scoped to RTL — LTR is byte-for-byte unchanged

All CSS is under :dir(rtl); the JS change only sets a custom property (LTR keeps using the same inline padding-inline-start it always did). Concretely: only the RTL visual snapshot changes — the other 8 snapshots are pixel-identical, and the field keeps the consumer's width with the dropdown aligned under it.

Testing

  • Visual snapshots regenerated in the pinned Docker/linux env; verified the RTL result (51 234 5678 +966 🇸🇦 in a full-width field, no overlap, a space before the dial code, dropdown aligned) and that the 8 non-RTL snapshots are unchanged.
  • Full node unit suite green (508 passing); typecheck clean; no test changes needed.

Base

Targets rtl-logical-properties so the diff is just this RTL layout on top of the logical-properties conversion.

@johnnyshields
johnnyshields force-pushed the rtl-dial-code-prefix branch from 89ec0f6 to 1f9a779 Compare July 6, 2026 05:15
@johnnyshields johnnyshields changed the title RTL: dial code as a left-hand prefix (flag stays on the right) RTL: right-align number with dial code as a left-hand prefix (flag stays right) Jul 6, 2026
@johnnyshields
johnnyshields force-pushed the rtl-dial-code-prefix branch from 1f9a779 to 9016480 Compare July 6, 2026 10:46
@johnnyshields johnnyshields changed the title RTL: right-align number with dial code as a left-hand prefix (flag stays right) RTL: right-align number with dial code as a left-hand prefix — pure CSS (flag stays right) Jul 6, 2026
…ayout)

Opinionated TableCheck RTL layout: the phone number is right-aligned so it sits
beside the country button, and the number, separate dial code and flag read as
one group hugging the flag — e.g. "51 234 5678 +966 🇸🇦".

- No direction detection in JS, and the dial code keeps ONE position (inside the
  country button, upstream default) that serves both LTR and RTL.
- Layout is pure CSS, scoped to :dir(rtl): right-align the number and move the
  flag-clearance padding to the input's physical inline-end.
- Why the one JS touch: browsers resolve a tel input's own direction as LTR even
  inside an RTL page, so ui.ts's flag-clearance padding-inline-start lands on the
  physical LEFT — the wrong side when the button is on the right. ui.ts now also
  publishes that already-measured width as the --iti-country-clearance custom
  property (a measurement only); the :dir(rtl) rule neutralises the left padding
  and re-applies the clearance on the right. The direction/side decision is 100%
  in CSS.

Only the RTL visual snapshot changes; the other 8 are byte-identical and the LTR
path is untouched. typecheck clean, e2e 17 passed, node unit suite 508 passed.
@johnnyshields
johnnyshields force-pushed the rtl-dial-code-prefix branch from 9016480 to a2d347d Compare July 6, 2026 13:12
@johnnyshields johnnyshields changed the title RTL: right-align number with dial code as a left-hand prefix — pure CSS (flag stays right) RTL: right-align number next to the flag/dial-code button (pure-CSS layout) Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant