Skip to content

feat(core): add logical start/end to Dialog position; deprecate physical left/right - #4568

Merged
nynexman4464 merged 8 commits into
mainfrom
nynexman4464/feat/dialog-position-logical
Aug 1, 2026
Merged

nynexman4464 merged 8 commits into
mainfrom
nynexman4464/feat/dialog-position-logical

Conversation

@nynexman4464

Copy link
Copy Markdown
Contributor

Why

Dialog's position prop exposes physical left/right offsets as consumer-facing API (DialogPosition { top, right, bottom, left }). Part of the RTL migration wanted these to become logical (inset-inline-start/end) so a positioned dialog mirrors under RTL. But silently flipping left/right to logical would be a breaking change — a consumer that set left: 20 expecting the visual-left edge would see their dialog jump to the right under RTL. So this ships a proper, non-breaking deprecation path instead of mutating the existing props (the physical→logical migration PR #4564 correspondingly excludes Dialog).

What

  • Add logical start/end to DialogPosition. They map to inset-inline-start / inset-inline-end and mirror under RTL — the preferred, RTL-safe way to anchor a dialog to an inline edge (start = left in LTR, right in RTL).
  • Deprecate left/right via @deprecated JSDoc. They still work and stay physical (never mirror) for backward-compat; slated for removal in a future major.
  • Non-breaking mapping: a consumer using ONLY left/right gets exactly today's behavior — physical offset, auto fallback, no mirroring.
  • Precedence: if both a logical offset and its physical counterpart are set (e.g. start and left), the logical one wins and the physical is suppressed so they can't fight. Documented on the interface.
  • Codemod: migrate-dialog-position-to-logical (packages/cli/codemods/transforms/v0.2.1/) rewrites <Dialog position={{left, right}}> → {{start, end}}. It's optional (left/right still work), import-alias/subpath aware, and skips ambiguous cases (a variable position, or left/right already coexisting with start/end).

Codemod: how to run

The repo's astryx upgrade runner picks it up for the 0.2.0 → 0.2.1 range via the codemod registry. To run just this transform directly with jscodeshift:

npx jscodeshift -t packages/cli/codemods/transforms/v0.2.1/migrate-dialog-position-to-logical.mjs \
  --parser=tsx 'src/**/*.{ts,tsx}'

Precedence rule

The physical→logical mapping + precedence lives inline in dynamicStyles.position (StyleX requires create() bodies to be inline object literals — it can't analyze a delegated helper). The identical logic is mirrored in the exported pure resolveDialogPositionOffsets() and unit-tested there (mirror mapping, physical stays physical, precedence, non-breaking equivalence).

Testing

  • pnpm --filter @astryxdesign/core typecheck — 0 errors
  • Dialog tests — 37 pass (incl. 6 new resolveDialogPositionOffsets cases)
  • Codemod tests — 11 pass
  • pnpm lint — 0 errors; pnpm check:repo — green

Semver note

Changeset is a feat (patch) — this is additive (start/end) plus a deprecation, with no break. Per the repo's 0.x policy ([breaking] → minor, everything else → patch), a non-breaking change must be a patch; check:changesets enforces this. (The task brief said "minor," but minor is the breaking tier here, so feat/patch is the correct, CI-passing category for a non-breaking change.)

Future-major removal plan

Once consumers have adopted start/end (aided by the codemod), a follow-up major removes left/right from DialogPosition and the physical branch from dynamicStyles.position, leaving only the logical offsets.

@vercel

vercel Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Jul 31, 2026 11:58pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 30, 2026
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Jul 30, 2026
@github-actions

github-actions Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

Dialog (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 644 -
Complexity N/A Very High (81) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.7KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Jul 31, 2026
github-actions Bot added a commit that referenced this pull request Jul 31, 2026
github-actions Bot added a commit that referenced this pull request Jul 31, 2026
github-actions Bot added a commit that referenced this pull request Jul 31, 2026
github-actions Bot added a commit that referenced this pull request Jul 31, 2026
github-actions Bot added a commit that referenced this pull request Jul 31, 2026
@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/dialog-position-logical branch from 72c25ef to a55fd82 Compare July 31, 2026 18:00
github-actions Bot added a commit that referenced this pull request Jul 31, 2026
@nynexman4464
nynexman4464 marked this pull request as ready for review July 31, 2026 23:24
@nynexman4464
nynexman4464 requested a review from ejhammond as a code owner July 31, 2026 23:24
…cal left/right

Dialog's `position` prop exposes physical `left`/`right` offsets. Silently
mapping those to logical inset-inline-start/end (so they mirror under RTL)
would be a breaking change: consumers relying on `left` meaning the visual-left
edge would see their dialogs jump to the other side under RTL. So instead of
flipping the existing props, this adds a proper deprecation path:

- Add logical `start`/`end` to DialogPosition. They map to
  `inset-inline-start`/`inset-inline-end` and MIRROR under RTL — the preferred,
  RTL-safe way to anchor a dialog to an inline edge.
- Deprecate `left`/`right` via @deprecated JSDoc. They still work and stay
  PHYSICAL (never mirror) for backward-compat; they'll be removed in a future
  major. A physical-only consumer gets EXACTLY today's behavior — non-breaking.
- Precedence: if both a logical offset and its physical counterpart are set,
  the logical one wins (the physical is suppressed so they can't fight).
- Ship a codemod (packages/cli/codemods/transforms/v0.2.1,
  `migrate-dialog-position-to-logical`) that rewrites
  `<Dialog position={{left, right}}>` to `{{start, end}}`. It is OPTIONAL
  (left/right still work) and alias/subpath-import aware; it skips ambiguous
  cases (a variable position, or left/right already coexisting with start/end).

The physical→logical mapping + precedence is unit-tested via a pure exported
`resolveDialogPositionOffsets` (the StyleX create() body must stay an inline
object literal, so the logic is mirrored there and tested here). Docs/story
(LogicalPosition) updated. Changeset is a `feat` (patch) — additive + a
deprecation, no break. Future-major follow-up: drop left/right after adoption.
@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/dialog-position-logical branch from a55fd82 to 3627dbb Compare July 31, 2026 23:55
@nynexman4464
nynexman4464 enabled auto-merge (squash) July 31, 2026 23:56
@nynexman4464
nynexman4464 merged commit 827f173 into main Aug 1, 2026
20 checks passed
github-actions Bot added a commit that referenced this pull request Aug 1, 2026
@github-actions
github-actions Bot deleted the nynexman4464/feat/dialog-position-logical branch August 1, 2026 06:54
nynexman4464 added a commit that referenced this pull request Aug 3, 2026
Consumer side: add an 'it just works' note (set dir once, components
mirror themselves) and correct the stale caveat that claimed overlays
(menus/dialogs) aren't mirrored yet -- they mirror via logical CSS
anchor positioning now (#4568 and the Layer logical placement).

Contributor side: replace the single 'read useDirection() to swap an
icon' example -- the exact anti-pattern this stack removes from
Pagination -- with a priority hierarchy: (1) logical CSS, (2) icons via
rtlStyles.mirror, (3) behavioral logic via lazy isRtlElement / focus-hook
auto-detect, (4) useDirection() context only as a render-time last resort.
Notes that isRtl on the focus hooks is deprecated and that no component
reads direction from context at render time after the CSS-mirror migration.
nynexman4464 added a commit that referenced this pull request Aug 4, 2026
Consumer side: add an 'it just works' note (set dir once, components
mirror themselves) and correct the stale caveat that claimed overlays
(menus/dialogs) aren't mirrored yet -- they mirror via logical CSS
anchor positioning now (#4568 and the Layer logical placement).

Contributor side: replace the single 'read useDirection() to swap an
icon' example -- the exact anti-pattern this stack removes from
Pagination -- with a priority hierarchy: (1) logical CSS, (2) icons via
rtlStyles.mirror, (3) behavioral logic via lazy isRtlElement / focus-hook
auto-detect, (4) useDirection() context only as a render-time last resort.
Notes that isRtl on the focus hooks is deprecated and that no component
reads direction from context at render time after the CSS-mirror migration.
nynexman4464 added a commit that referenced this pull request Aug 4, 2026
Consumer side: add an 'it just works' note (set dir once, components
mirror themselves) and correct the stale caveat that claimed overlays
(menus/dialogs) aren't mirrored yet -- they mirror via logical CSS
anchor positioning now (#4568 and the Layer logical placement).

Contributor side: replace the single 'read useDirection() to swap an
icon' example -- the exact anti-pattern this stack removes from
Pagination -- with a priority hierarchy: (1) logical CSS, (2) icons via
rtlStyles.mirror, (3) behavioral logic via lazy isRtlElement / focus-hook
auto-detect, (4) useDirection() context only as a render-time last resort.
Notes that isRtl on the focus hooks is deprecated and that no component
reads direction from context at render time after the CSS-mirror migration.
nynexman4464 added a commit that referenced this pull request Aug 4, 2026
…direction read (#4687)

* refactor(core): mirror Pagination chevrons under RTL via CSS, not JS direction read

Pagination was the last component selecting a physical icon name from a
render-time useDirection() read. Switch it to render fixed chevronLeft/
chevronRight glyphs wrapped in the shared rtlStyles.mirror (scaleX(-1)),
so they flip purely from an ancestor's dir via the CSS cascade -- matching
Calendar and the rest of the library. This removes the only internal
consumer of the i18n direction context and eliminates a potential
server/client hydration mismatch on the chevrons. No API change.

* docs(i18n): align RTL guidance with the CSS-mirror model

Consumer side: add an 'it just works' note (set dir once, components
mirror themselves) and correct the stale caveat that claimed overlays
(menus/dialogs) aren't mirrored yet -- they mirror via logical CSS
anchor positioning now (#4568 and the Layer logical placement).

Contributor side: replace the single 'read useDirection() to swap an
icon' example -- the exact anti-pattern this stack removes from
Pagination -- with a priority hierarchy: (1) logical CSS, (2) icons via
rtlStyles.mirror, (3) behavioral logic via lazy isRtlElement / focus-hook
auto-detect, (4) useDirection() context only as a render-time last resort.
Notes that isRtl on the focus hooks is deprecated and that no component
reads direction from context at render time after the CSS-mirror migration.

* docs(i18n): use headings for RTL priority tiers, not markdown bold

The docsite prose renderer (renderInlineMarkdown) only supports backtick
code-spans and [label](href) links -- **bold** renders as literal
asterisks. Convert the four contributor priority tiers from fake-bold
prose lead-ins into real level-4 headings + prose, which the renderer
supports and which gives proper visual hierarchy. Code identifiers stay
in the prose (where backticks work), since headings render text
verbatim.

* docs(i18n): reframe useDirection() JSDoc as a render-time last resort

The hook's own doc-comment still told authors to reach for it to 'swap
directional icons' -- the exact pattern the Pagination refactor and the
updated guide move away from. Reframe it to point at the preferred tools
first (logical CSS, rtlStyles.mirror for icons, lazy isRtlElement for
behavior) and note the hydration caveat, so IDE hovers and the API
surface match the guidance. Comment-only.

* docs(i18n): document that the provider does NOT set <html dir>

The provider's dir prop feeds context direction only; it never touches
the DOM dir attribute. Since astryx components mirror layout and
directional icons from the DOM dir (not the context value), an RTL
locale won't visually mirror unless the consumer also sets dir on <html>
or a wrapping element. Make this explicit where a provider user will
look: add the previously-undocumented dir prop to the component doc, a
best-practice entry, and expand the dir JSDoc (IDE hover). Docs only.

This branch was successfully deployed

1 active deployment
Preview — 3627dbb7 Deployed Jul 31, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant