Skip to content

feat(core): export isRtlElement from @astryxdesign/core/hooks - #8330

Closed
vjeux wants to merge 2 commits into
meta:mainfrom
vjeux:uikit/c15-is-rtl-element
Closed

vjeux wants to merge 2 commits into
meta:mainfrom
vjeux:uikit/c15-is-rtl-element

Conversation

@vjeux

@vjeux vjeux commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

User need

Lab components that drag, scroll or lay out by writing direction (the tab bar's lens, the search field, the navigation stack's swipe back) read the direction inline with getComputedStyle(el).direction. Core already has the one helper for this, isRtlElement, used by list and grid focus, Carousel and swipe actions, but no package export carries it, so lab can't use it and each component keeps its own read. Review asked for one implementation (design:bidirectionality DR13: drag, resize and scroll outcomes mirror).

Problem and solution fit

Exporting the existing helper from @astryxdesign/core/hooks lets every lab component read the direction the way core does. Nothing else changes.

Current specification

Proposed; pending owner review: this adds isRtlElement to core's public surface. useDirection (the i18n context's direction) already names isRtlElement as the read for behavioral logic such as drag math; this PR only makes it importable.

Public delta and caller burden

  • New export: isRtlElement(el: HTMLElement | null): boolean from @astryxdesign/core/hooks.
  • SSR-safe (false with no element or no DOM). Call it when the direction is needed (in an event or an effect), not during render.
import {isRtlElement} from '@astryxdesign/core/hooks';

const sign = isRtlElement(element) ? -1 : 1;

Design and alternatives

  • Rejected: each lab component exporting or copying its own helper (four components need it).
  • Rejected: useDirection alone. It answers the provider's direction during render, not the computed direction of an element inside a dir="rtl" region.

Evidence

Unit tests: it is exported from the hooks entry; it reads right to left and the left-to-right default; it is false for no element.

Scope

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm exec vitest run packages/core/src/hooks (506 passed)
  • pnpm -F @astryxdesign/core typecheck, pnpm check:changesets, ESLint and Prettier on the touched files

@vercel

vercel Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 26, 2026 4:44am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Oct 26, 2026, 6:34 AM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 24, 2026
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 24, 2026
… isRtlElement

Review follow-up (one implementation per behaviour): the touch layer's
geometry asks core's `isRtlElement` (exported from
`@astryxdesign/core/hooks` by meta#8330, merged below) instead of reading the
computed `direction` itself. No behaviour change; the right-to-left proofs
pass as before.

@astracat-bot astracat-bot Bot 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.

Approval waits on an engineering owner deciding whether isRtlElement should join @astryxdesign/core's public API at @astryxdesign/core/hooks, which through export * from './hooks' also exposes it from the package root: no current spec covers that addition. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so if they are an engineering owner. Separately, please remove “(proposed; pending owner review)” from the changeset and the isRtlElement.ts header before landing, since the changeset text is published in the CHANGELOG, and name every entry point the export ships on.

[Automated review]

Comment thread .changeset/hooks-is-rtl-element.md Outdated
'@astryxdesign/core': patch
---

[feat] `isRtlElement` is exported from `@astryxdesign/core/hooks` (proposed; pending owner review): whether an element renders right to left, read from its computed `direction` when it is called, for drag, scroll and layout math.

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.

This text is published in the CHANGELOG; the formatter renders it as “- [feat] isRtlElement is exported from @astryxdesign/core/hooks (proposed; pending owner review): …”. Once an owner decides, please drop “(proposed; pending owner review)” and name every entry point the export ships on: export * from './hooks' in packages/core/src/index.ts also exports it from @astryxdesign/core.

Comment thread packages/core/src/hooks/isRtlElement.ts Outdated
Comment on lines +10 to +11
* @position Exported from `@astryxdesign/core/hooks` (proposed; pending
* owner review); used by useListFocus and useGridFocus to auto-detect RTL

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.

“(proposed; pending owner review)” would stay in the shipped source after the decision; please drop it together with the changeset wording.

vjeux added a commit to vjeux/astryx that referenced this pull request Oct 25, 2026
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 25, 2026
…isRtlElement

One implementation of direction detection (design:bidirectionality DR13):
the stack asks core's isRtlElement, exported from @astryxdesign/core/hooks
by meta#8330, instead of reading the computed direction itself.
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 25, 2026
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 25, 2026
… isRtlElement

Review follow-up (one implementation per behaviour): the touch layer's
geometry asks core's `isRtlElement` (exported from
`@astryxdesign/core/hooks` by meta#8330, merged below) instead of reading the
computed `direction` itself. No behaviour change; the right-to-left proofs
pass as before.
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 25, 2026
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 25, 2026
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 25, 2026
… isRtlElement

Review follow-up (one implementation per behaviour): the touch layer's
geometry asks core's `isRtlElement` (exported from
`@astryxdesign/core/hooks` by meta#8330, merged below) instead of reading the
computed `direction` itself. No behaviour change; the right-to-left proofs
pass as before.
@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Component Size

Component Import before Import after Delta CSS before CSS after Delta
core/AlertDialog 54.4KB 54.4KB 0B 12.4KB 12.4KB 0B
core/AvatarGroup 39.6KB 39.6KB 0B 6.4KB 6.4KB 0B
core/BottomSheet 26.0KB 26.0KB 0B 7.7KB 7.7KB 0B
core/BottomSheetSwitcher 9.2KB 9.2KB 0B 3.3KB 3.3KB 0B
core/BreadcrumbItem 65.7KB 65.7KB 0B 11.0KB 11.0KB 0B
core/ButtonGroup 8.4KB 8.4KB 0B 3.3KB 3.3KB 0B
core/Calendar 54.7KB 54.7KB 0B 10.0KB 10.0KB 0B
core/Carousel 48.7KB 48.7KB 0B 10.2KB 10.2KB 0B
core/CheckboxInput 49.3KB 49.3KB 0B 9.3KB 9.3KB 0B
core/CheckboxList 45.8KB 45.8KB 0B 8.1KB 8.1KB 0B
core/CheckboxListItem 53.4KB 53.5KB +41B 10.5KB 10.5KB 0B
core/ComplexSelector 55.1KB 55.1KB 0B 10.6KB 10.6KB 0B
core/ContextMenu 77.1KB 77.1KB 0B 14.4KB 14.4KB 0B
core/ContextMenuItem 16.6KB 16.6KB +1B 5.2KB 5.2KB 0B
core/DateInput 92.7KB 92.7KB 0B 14.6KB 14.6KB 0B
core/DateRangeInput 64.3KB 64.3KB 0B 11.2KB 11.2KB 0B
core/DateTimeInput 102.0KB 102.0KB 0B 15.0KB 15.0KB 0B
core/Drawer 25.6KB 25.6KB 0B 8.0KB 8.0KB 0B
core/DropdownMenu 72.1KB 72.1KB +1B 14.5KB 14.5KB 0B
core/DropdownMenuCheckboxItem 16.1KB 16.1KB 0B 5.6KB 5.6KB 0B
core/DropdownMenuItem 15.4KB 15.4KB 0B 5.2KB 5.2KB 0B
core/DropdownMenuRadioItem 16.2KB 16.2KB 0B 5.6KB 5.6KB 0B
core/DropdownMenuSubMenu 57.4KB 57.4KB 0B 9.5KB 9.5KB 0B
core/Field 44.0KB 44.0KB 0B 8.0KB 8.0KB 0B
core/FieldLabel 39.6KB 39.6KB 0B 6.5KB 6.5KB 0B
core/FileInput 53.6KB 53.6KB 0B 10.3KB 10.3KB 0B
core/InputGroup 44.6KB 44.6KB 0B 8.0KB 8.0KB 0B
core/Item 11.4KB 11.4KB 0B 4.7KB 4.7KB 0B
core/Lightbox 49.4KB 49.4KB 0B 9.8KB 9.8KB 0B
core/ListItem 52.9KB 52.9KB +47B 10.5KB 10.5KB 0B
core/Markdown 141.9KB 141.9KB -1B 17.1KB 17.1KB 0B
core/MoreMenu 72.3KB 72.3KB 0B 14.5KB 14.5KB 0B
core/MultiSelector 75.5KB 75.5KB -18B 14.4KB 14.4KB 0B
core/NavHeadingMenu 8.9KB 8.9KB 0B 3.2KB 3.2KB 0B
core/NumberInput 55.5KB 55.5KB 0B 10.7KB 10.7KB 0B
core/Outline 28.6KB 28.6KB 0B 4.0KB 4.0KB 0B
core/Pagination 87.2KB 87.2KB -3B 15.1KB 15.1KB 0B
core/PowerSearch 147.6KB 147.6KB +1B 18.4KB 18.4KB 0B
core/RadioList 45.4KB 45.4KB -1B 8.0KB 8.0KB 0B
core/RadioListItem 52.0KB 52.0KB +37B 9.7KB 9.7KB 0B
core/SegmentedControl 38.7KB 38.7KB 0B 6.3KB 6.3KB 0B
core/Selector 78.6KB 78.6KB +17B 14.8KB 14.8KB 0B
core/SelectorOption 14.5KB 14.5KB 0B 5.1KB 5.1KB 0B
core/SideNavHeading 54.6KB 54.6KB 0B 10.1KB 10.1KB 0B
core/SideNavItem 54.3KB 54.3KB 0B 10.1KB 10.1KB 0B
core/Slider 48.3KB 48.3KB 0B 8.5KB 8.5KB 0B
core/Switch 48.2KB 48.2KB 0B 9.3KB 9.3KB 0B
core/TabList 40.0KB 40.0KB 0B 7.2KB 7.2KB 0B
core/TabMenu 51.5KB 51.5KB 0B 10.0KB 10.0KB 0B
core/Table 83.3KB 83.3KB +1B 14.9KB 14.9KB 0B
core/TableCell 78.2KB 78.2KB -2B 14.6KB 14.6KB 0B
core/TableHeaderCell 78.0KB 78.0KB -2B 14.5KB 14.5KB 0B
core/TableSelectionToolbar 52.2KB 52.2KB 0B 11.2KB 11.2KB 0B
core/TextArea 48.8KB 48.8KB 0B 9.4KB 9.4KB 0B
core/TextInput 53.0KB 53.0KB 0B 10.5KB 10.5KB 0B
core/TimeInput 79.2KB 79.2KB 0B 13.5KB 13.5KB 0B
core/Tokenizer 64.2KB 64.2KB 0B 11.7KB 11.7KB 0B
core/Toolbar 39.6KB 39.6KB 0B 7.7KB 7.7KB 0B
core/TopNavHeading 54.0KB 54.0KB 0B 9.9KB 9.9KB 0B
core/TopNavMegaMenu 54.0KB 54.0KB 0B 10.7KB 10.7KB 0B
core/TopNavMenu 53.5KB 53.5KB 0B 10.1KB 10.1KB 0B
core/TreeList 32.5KB 32.5KB 0B 4.7KB 4.7KB 0B
core/Typeahead 60.8KB 60.8KB 0B 11.3KB 11.3KB 0B

Sizes are gzip. Import counts the JavaScript the import loads eagerly; CSS counts the package stylesheet rules referenced by the modules it can load from its own package, lazily loaded ones included.

Bundle Size Summary

Gzip figures measure each package's entry file, not the code an import pulls in.

Package Entry (ESM) Entry gzip before Entry gzip after Delta
@astryxdesign/core 4.9KB 1.2KB 1.2KB 0B
Package stylesheet Gzip before Gzip after Delta
@astryxdesign/core 34.2KB 34.2KB 0B

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

55 of 502 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 753,933
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,072
RichTextEditor Markdown parity: side by side probe dark 558,840
RichTextEditor Markdown parity: side by side probe light 540,756
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
AppShell With Mobile Nav probe light 217,010
AppShell With Mobile Nav probe dark 216,960
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
AppShell Playground neutral dark 65,198
AppShell Playground neutral light 63,788
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232

and 35 more.


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

vjeux added a commit to vjeux/astryx that referenced this pull request Oct 25, 2026
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 25, 2026
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 25, 2026
…n lens

A capsule of tabs floating above the bottom edge, with UIKit's measured
geometry (62 px capsule 21 px from the edges, 76 x 54 items 4 px inside
it) and a selection lens that carries the selected look: the items are
drawn twice and the selected copy lives inside the lens, counter-
translated, so an item half under a sliding lens is half tinted. Under a
finger (a coarse primary pointer, iOS and Android alike: one touch model,
AST-094) the lens slides on core's animator with UIKit's spring (response
0.4 s, damping ratio 0.85), keeping its speed when a second tap turns it
around; that motion is TabBar's touch layer, TabBarTouch.ts, its one import
site. Under a mouse the lens slides in CSS on the theme's duration and
easing (keyed on the touch query, spelled as the resolver's constant), and
no touch code runs. Under Reduce
Motion nothing travels
(design:reduced-motion, applied by the animator): on a touch screen the
lens cross-fades in 200 ms, under a mouse it moves at once. Choosing the
selected tab again calls onReselect. Badges sit over the icon's
top-trailing corner and never animate. The tabs are a named tablist with
one tab stop. The lens is one element per role: its resting fill is its
own background.

Values live in motion/uikit/tabBar.ts, read from a stock
UITabBarController on iOS 26.2; the table is registered, so each spring
is a motion role a theme may retune (tabBar.lensTravel).

The bar sets no page-level stacking rank: its root isolates its own layers
(the lens and the badges order inside it). A badge's spoken suffix comes
from the message catalog (@astryx.tabBar.badge, ", {badge}"), separator
included. The docs and stories declare the bar on LayerProvider
(inset={{blockEnd: 83}}) so menus, popovers and toasts clear it. Writing
direction comes from core's isRtlElement (exported by meta#8330).
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 25, 2026
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 25, 2026
…n lens

A capsule of tabs floating above the bottom edge, with UIKit's measured
geometry (62 px capsule 21 px from the edges, 76 x 54 items 4 px inside
it) and a selection lens that carries the selected look: the items are
drawn twice and the selected copy lives inside the lens, counter-
translated, so an item half under a sliding lens is half tinted. Under a
finger (a coarse primary pointer, iOS and Android alike: one touch model,
AST-094) the lens slides on core's animator with UIKit's spring (response
0.4 s, damping ratio 0.85), keeping its speed when a second tap turns it
around; that motion is TabBar's touch layer, TabBarTouch.ts, its one import
site. Under a mouse the lens slides in CSS on the theme's duration and
easing (keyed on the touch query, spelled as the resolver's constant), and
no touch code runs. Under Reduce
Motion nothing travels
(design:reduced-motion, applied by the animator): on a touch screen the
lens cross-fades in 200 ms, under a mouse it moves at once. Choosing the
selected tab again calls onReselect. Badges sit over the icon's
top-trailing corner and never animate. The tabs are a named tablist with
one tab stop. The lens is one element per role: its resting fill is its
own background.

Values live in motion/uikit/tabBar.ts, read from a stock
UITabBarController on iOS 26.2. registerTabBarTable() beside the data makes
each spring a motion role a theme may retune (tabBar.lensTravel); nothing
registers on import, and TabBar's touch layer calls it under a finger
before its first animation.

The bar sets no page-level stacking rank: its root isolates its own layers
(the lens and the badges order inside it). A badge's spoken suffix comes
from the message catalog (@astryx.tabBar.badge, ", {badge}"), separator
included. The docs and stories declare the bar on LayerProvider
(inset={{blockEnd: 83}}) so menus, popovers and toasts clear it. Writing
direction comes from core's isRtlElement (exported by meta#8330).
An element's computed `direction`, read when it is called, so a component
doing drag, scroll or layout math asks once instead of detecting it inline.
useListFocus, useGridFocus, Carousel and the swipe actions already read it
inside core; lab's TabBar reads the same helper for its lens.

The changeset and the file header no longer carry "proposed; pending owner
review": what ships is the export, and the question of its contract belongs
in the pull request, not in the CHANGELOG.
@vjeux
vjeux force-pushed the uikit/c15-is-rtl-element branch from dc9d16a to 36d487c Compare October 26, 2026 04:19
@vjeux

vjeux commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Fixed at 36d487c: neither the changeset nor the file header says "proposed; pending owner review" any more. The changeset describes what ships — the export and what it reads — and the open question, whether a utility like this belongs on the stable hooks entry at all (spec:AST-017 FR21) or stays internal for Lab to reach by module path, is the decision this PR asks for. That is the same question cixzhang has open on #8076 for Lab's other core imports, so the two should be settled together; I have not changed the path meanwhile.

@vjeux

vjeux commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

The typecheck and build red on the previous head came from this branch's base, not from the change: packages/lab/src/MobileTokenizer/MobileTokenizer.test.tsx typed a spy as ReturnType<typeof vi.fn>, which stopped typechecking once lab's tests joined the typecheck list, and main has since typed it as a plain function. This branch touched four files, none of them that one, and CI said as much in the log: "Running the previous typecheck list; merge main to use pnpm typecheck."

Merged main (b298b37) at 4aa6e4a — no conflicts. On it: pnpm build clean, root pnpm typecheck 0 errors, core hooks tests 519 passed.

@astracat-bot astracat-bot Bot 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.

Approval waits on an engineering owner providing or identifying the spec that governs this addition: no current spec gives isRtlElement a public contract, spec:AST-017 FR21 keeps a utility without one unexported, and through export * from './hooks' the export reaches the @astryxdesign/core root as well as @astryxdesign/core/hooks. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request to approve the export as proposed, and the author may do so as an engineering owner; alternatively an owner can name another entry point, such as @astryxdesign/core/i18n or @astryxdesign/core/utils, or keep the helper internal, in which case the export comes out. No other change is needed: the export adds only isRtlElement to those two entry points, and the earlier release-note wording is fixed.

[Automated review]

@vjeux

vjeux commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Closing this: nothing needs the export any more.

Both consumers now read the writing direction from Lab's own one-liner (packages/lab/src/utils/isRtlElement.ts, with its own test) — TabBar in its three hooks, SearchField in its touch layer — so the helper stays off core's stable hooks barrel, which is what the review asked for under spec:AST-017 FR21. Core's components keep importing their copy directly, as they always did.

That leaves this pull request with no content anyone depends on, so it goes rather than lingering as an open decision.

@vjeux vjeux closed this Oct 26, 2026
@vjeux
vjeux deleted the uikit/c15-is-rtl-element branch October 26, 2026 09:55
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 26, 2026
…-off

The stack keeps meta#8330's `isRtlElement` hooks export, which meta#8181 no longer
carries (it has a Lab-local one).
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 26, 2026
The stack keeps meta#8330's `isRtlElement` hooks export, which meta#8181 no longer
carries; the motion README keeps the list table's row with meta#8181's search
row.
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 26, 2026
The two bases merged with none of this PR's own change, so a compare from
here shows only that change. It keeps meta#8330's `isRtlElement` hooks export
and the motion README's list row, as this branch does.
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 27, 2026
…rnal entry

meta#8330, which would have exported `isRtlElement` from
`@astryxdesign/core/hooks`, is closed: the helper stays off Core's stable
`hooks` entry (`spec:AST-017` FR21). This pull request no longer carries
that export, its changeset, its test or its header edit. PageControl takes
Core's one `isRtlElement` through `@astryxdesign/core/internal/touch`
instead, as a named re-export with its line in
scripts/core-internal-entries.test.mjs, so Lab and Core read the direction
with one implementation and nothing new is public.

PageControl.tsx's header now names the internal entries it imports from.
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 27, 2026
…gh Core's internal entry

PageControl.tsx and PageControlTouch.ts take Core's `isRtlElement`
through `@astryxdesign/core/internal/touch`, which meta#8164 now re-exports
by name in place of meta#8330's closed public export. PageControl.tsx's
header names the internal entries and the touch layer it imports.

This branch was successfully deployed

1 active deployment
Preview — 4aa6e4a5 Deployed Oct 26, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant