Repository navigation
Commit ccdfe62
fix(components): in a right-to-left language the desktop sidebar sits beside the page instead of over its header (#38213)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoNZP1tN1FWjFR4ejvdtt1bb)_
Fixes #37914
repo:objectstack#3 · os-tesla · session_01L9qibvkagpUt9LtVz1U4MM
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 界面语言是阿拉伯语时,桌面上的侧边栏改到右边、紧挨页面内容,不再从左边盖住页面末端;页头的按钮、帮助、评论和「问
AI」都看得见、点得到。收起、悬停浮出、拖宽和无页头页面上的展开按钮也都跟着换到右边。
- 替用阿拉伯语界面的桌面用户解决:每个应用的每个页面,页面左边 256 像素被侧边栏挡住,右边却空着一条。
- 只改侧边栏放在哪一边,从左到右的语言一个像素不变(逐项量过);出问题最多是阿拉伯语下侧边栏位置不对,可以直接撤回。
- 无
## What changes
- `ui/packages/components/src/ui/sidebar.tsx` (shadcn primitive,
declared patches only): the desktop panel, its divider and the edge rail
are placed with logical insets. `side="left"` is the document's inline
start, `side="right"` its end, as the in-flow gap already was:
`left-0`/`right-0` and the collapsed offsets become `start-*`/`end-*`,
the divider `border-e`/`border-s`, the rail's offsets and hover line
`start-*`/`end-*`, its half-width shift gets `rtl:translate-x-1/2`, and
its resize cursors get `rtl:` mirrors (expanded and collapsed). In a
left-to-right document every logical inset computes to the physical one
it replaces.
- `ui/scripts/shadcn-local-patches.mjs`: a new declared family,
`sidebarLogicalInsetPatches` (objectstack#37914: divider, rail, the two
cursor lines), anchored on
`scripts/__tests__/fixtures/shadcn-registry/sidebar.registry.txt`,
markers = the whole patched strings. The offcanvas family
(objectui#11464) now writes its panel offsets and rail edge offsets in
the logical spelling; its doc block says how.
`packages/components/shadcn-components.json` `localEdits` names the new
family.
- `ui/packages/app-shell/src/layout/consoleSidebarRail.ts`:
`SIDEBAR_EDGE_ZONE` (the strip that floats a hidden sidebar) is
`start-0`; `RAIL_OVERLAY_PANEL` is `start-2` and `RAIL_HIDDEN_PANEL`
parks with `start-[...]`. New `isRightToLeft(el)` (nearest `dir` says
`rtl`). `pointerOnFloat`, which decides whether a hover-opened float
folds, measured its margin and side from the window's left edge; it now
reads the start edge, so in RTL a pointer over the page folds the float
(this site was not in the pre-claim list; it is in the claimed file and
its premise, panel at the left, is what the primitive change makes
false).
- `ui/packages/app-shell/src/layout/SidebarWidthHandle.tsx`: the handle
is `-end-1`; a drag and the arrow keys toward the page widen the sidebar
in either direction (the drag's sign and the arrow step flip in RTL).
- `ui/packages/app-shell/src/layout/ShellPageActions.tsx`:
`ShellSidebarExpandFallback` is `start-2`, opposite the assistant's
fallback (`end-2`). On main in RTL both sat in the top-left corner and
overlapped (readings below).
- Changeset `.changeset/37914-sidebar-right-to-left.md`:
`@object-ui/components` patch, `@object-ui/app-shell` patch.
## Tests
- `ui/e2e/sidebar-offcanvas-geometry.spec.ts` (Chromium, real primitive
source, real Tailwind): new describe `the sidebar in a right-to-left
document`. (1) expanded `offcanvas` and `icon` in RTL: panel 1024..1280,
page 0..1024, gap 256, divider on the left. (2) all eight primitive
cases (offcanvas/icon × left/right × expanded/collapsed): the RTL panel,
page, gap, divider, rail box and rail cursor equal the LTR reading
mirrored. The six existing LTR cases are unchanged and green.
- `ui/scripts/__tests__/shadcn-local-patches.test.ts`: the new family's
ids; each replacement read back through the LTR mapping keeps upstream's
classes and adds only `rtl:` mirrors; no physical inset is left between
the desktop gap and `SidebarRail`; the offcanvas family's invariant
reads the logical spelling back; the sidebar carries six families.
-
`ui/packages/app-shell/src/layout/__tests__/SidebarWidthHandle.rightToLeft-37914.test.tsx`
(new): drag and arrow keys in LTR (control) and RTL.
- Updated pins that named the old classes:
`UnifiedSidebar.hiddenCollapse-35062.test.tsx` (the float card is
`start-2`), `sidebar-side-registration-11070.test.tsx`
(`end-0`/`start-0`; also a module-top `@object-ui/react-runtime` import,
which `check:test-source-alias` asks of an edited test that reaches it).
<details><summary>Ablation (at 400674f, sidebar.tsx put back to main's
bytes, then restored)</summary>
- `sidebar-offcanvas-geometry.spec.ts`: the two RTL tests fail (panel
0..256 where 1024..1280 is expected; divider `["0px","1px"]` where
`["1px","0px"]`), the six LTR tests pass.
- `shadcn-local-patches.test.ts`: 2 fail (`sidebar declares the
logical-inset patches`, `sidebar.tsx carries its declared patches`), 86
pass.
- `SidebarWidthHandle.tsx` put back to main's bytes: the two RTL cases
fail, the two LTR cases pass.
</details>
<details><summary>Real console readings, before (main's four source
files) and after (400674f source; the later commits change tests
only)</summary>
Showcase app booted from this tree (`objectstack dev --seed-admin`), the
console served from `ui/` source by Vite and pointed at it, Chromium
1280×800, `objectui-locale=ar` (and `en` as the control). Script and
full readings: the card thread's project files
(`console-rtl/measure.js`, `readings-400674f7.txt`).
| Reading (Arabic) | Before | After |
|---|---|---|
| List page: panel / main | 0..256 / 0..1024 | 1024..1280 / 0..1024 |
| List page: header group 16..48, overlap with panel | 32 px | 0 |
| Record page: panel / main | 0..256 / 0..1024 | 1024..1280 / 0..1024 |
| Record page: header group 8..40, overlap; help button hit-test | 32
px; covered | 0; clickable |
| Dashboard: panel / main | 0..256 / 0..1024 | 1024..1280 / 0..1024 |
| Dashboard: header group 24..297, overlap | 232 px | 0 |
| Resize edge; a 40 px drag toward the page | 251..259; 256→296 (drag
+40) | 1021..1029; 256→296 (drag −40) |
| Hidden: edge strip; parked card | 0..8; −288..−32 | 1272..1280;
1312..1568 |
| Float (hover on the strip): card | 8..264 | 1016..1272 |
| Float, pointer moved to x 640: card | parked again | parked again |
| Search page, collapsed: expand button / assistant button | 8..36 /
8..186 (overlap) | 1244..1272 / 8..186 |
- On main in Arabic the page header itself is drawn above the panel on
the list and dashboard pages (its buttons hit-test as clickable), but
the panel covers the first 256 px of the content under it (the
dashboard's first KPI card and first chart are hidden) and the sidebar's
own top row is under the page header; on the record page the header's
help button is under the panel.
- English, before and after: identical readings in every row (panel
0..256, main 256..1280, handle 251..259, strip 0..8, card 8..264, expand
8..36, assistant 1186..1272).
- FIXTURE in the search-page row only: the runtime here serves no agent,
so the assistant fallback would not draw; one stub agent in the
catalogue response turns it on for that reading.
</details>
## Acceptance notes
- Phone: the drawer (`Sheet side="left"`) still slides in from the left
in Arabic, and the drawer's swipe gesture (`UnifiedSidebar.tsx`, the
touch handlers) reads `clientX` in the left-to-right sense. Both are
phone-only and out of this card's scope (seat's claim); not measured.
- `data-side` keeps the words `left`/`right`; they now mean the inline
start and end. No consumer in the tree passes `side="right"` to the
console sidebar today.
## Verification
Read first (by risk):
1. `ui/scripts/shadcn-local-patches.mjs`: the offcanvas family's two
offset replacements and the new `sidebarLogicalInsetPatches`, against
`sidebar.tsx` lines 262-268 and 328-333.
2. `consoleSidebarRail.ts` `pointerOnFloat`: the float-away test in RTL.
3. `SidebarWidthHandle.tsx`: `toward` and the arrow `step`.
Two-minute check: switch the console language to Arabic at a desktop
width and open any list page: the sidebar is on the right and the page
header's buttons on the left are all visible.
<details><summary>Local gates at 7bc711b (base origin/main 7605e0c;
merges cleanly onto e3bdc74)</summary>
- `node scripts/pm/dispatch-gates.mjs --commands`: 42 families derived;
all 42 run, each with its exit code (`gates-ran-7bc711bf.list` in the
card thread's project files). 40 ran at 400674f and exited 0; `pnpm
check:test-source-alias` and `pnpm --dir ui exec vitest run scripts/`
exited 1 there (the first was a real finding in an edited test, fixed in
7bc711b; the second was killed by the container's memory limit while
another run shared it) and both exit 0 at 7bc711b. `--ran`: "42 run, 0
NOT-MEASURED (a DERIVED zero)".
- `pnpm --filter @object-ui/components type-check`: exit 0. `pnpm
--filter @object-ui/app-shell type-check`: exit 0.
- `vitest run packages/app-shell/src/layout/` (175 files): 1 failure at
400674f (`UnifiedSidebar.hiddenCollapse-35062`, the `left-2` pin),
fixed in 08ef3cc; that file 33/33 after. The 60 test files under
`packages/components` and `packages/layout` that mention the sidebar:
638/639 at 400674f, the one failure (`sidebar-side-registration-11070`,
the `right-0` pin) fixed in 08ef3cc, 5/5 after. The packages' full
suites: CI.
- `ui/e2e/sidebar-offcanvas-geometry.spec.ts` in Chromium: 8/8.
- `overlap-check.mjs`: `VERDICT clean exit 0` against origin/main
e3bdc74, 0 open PR heads share a file.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibvkagpUt9LtVz1U4MM)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent fd06b7a commit ccdfe62
12 files changed
Lines changed: 374 additions & 52 deletions
File tree
- .changeset
- ui
- e2e
- packages
- app-shell/src/layout
- __tests__
- components
- src
- renderers/__tests__
- ui
- scripts
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
70 | 74 | | |
71 | 75 | | |
72 | 76 | | |
| |||
271 | 275 | | |
272 | 276 | | |
273 | 277 | | |
| 278 | + | |
274 | 279 | | |
| 280 | + | |
| 281 | + | |
275 | 282 | | |
276 | 283 | | |
277 | | - | |
| 284 | + | |
278 | 285 | | |
279 | 286 | | |
280 | 287 | | |
281 | | - | |
282 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
283 | 295 | | |
284 | 296 | | |
285 | 297 | | |
| |||
321 | 333 | | |
322 | 334 | | |
323 | 335 | | |
| 336 | + | |
324 | 337 | | |
325 | 338 | | |
| 339 | + | |
326 | 340 | | |
327 | 341 | | |
328 | 342 | | |
| |||
431 | 445 | | |
432 | 446 | | |
433 | 447 | | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
188 | 190 | | |
189 | 191 | | |
190 | 192 | | |
| |||
197 | 199 | | |
198 | 200 | | |
199 | 201 | | |
200 | | - | |
| 202 | + | |
201 | 203 | | |
202 | 204 | | |
203 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
| |||
73 | 77 | | |
74 | 78 | | |
75 | 79 | | |
76 | | - | |
| 80 | + | |
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
80 | 84 | | |
81 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
82 | 91 | | |
83 | 92 | | |
84 | 93 | | |
85 | 94 | | |
86 | 95 | | |
87 | 96 | | |
88 | | - | |
| 97 | + | |
89 | 98 | | |
90 | 99 | | |
91 | 100 | | |
| |||
98 | 107 | | |
99 | 108 | | |
100 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
101 | 113 | | |
102 | | - | |
103 | | - | |
| 114 | + | |
| 115 | + | |
104 | 116 | | |
105 | 117 | | |
106 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
833 | 833 | | |
834 | 834 | | |
835 | 835 | | |
836 | | - | |
837 | | - | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
838 | 839 | | |
| 840 | + | |
839 | 841 | | |
840 | 842 | | |
841 | 843 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
337 | 339 | | |
338 | | - | |
| 340 | + | |
339 | 341 | | |
340 | 342 | | |
341 | 343 | | |
| |||
349 | 351 | | |
350 | 352 | | |
351 | 353 | | |
352 | | - | |
353 | | - | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
354 | 358 | | |
355 | 359 | | |
356 | | - | |
| 360 | + | |
357 | 361 | | |
358 | 362 | | |
359 | 363 | | |
360 | | - | |
| 364 | + | |
361 | 365 | | |
362 | 366 | | |
363 | | - | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
364 | 378 | | |
365 | 379 | | |
366 | 380 | | |
| |||
400 | 414 | | |
401 | 415 | | |
402 | 416 | | |
403 | | - | |
404 | | - | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
405 | 423 | | |
406 | 424 | | |
407 | 425 | | |
| |||
0 commit comments