Skip to content

Skip justify-self: flex-end on RTL table inside RTL container#3345

Open
JiuqingSong wants to merge 2 commits into
masterfrom
fix-rtl-table-nested-justify-self
Open

Skip justify-self: flex-end on RTL table inside RTL container#3345
JiuqingSong wants to merge 2 commits into
masterfrom
fix-rtl-table-nested-justify-self

Conversation

@JiuqingSong
Copy link
Copy Markdown
Collaborator

Summary

  • An RTL <table> currently always emits justify-self: flex-end to align it to the right edge of an LTR parent. When the parent context is already RTL, the table aligns correctly via RTL flow and the extra justify-self causes visual misalignment.
  • directionFormatHandler now reads context.implicitFormat.direction and skips justify-self: flex-end when the parent context is already RTL.
  • handleTable (cell children), handleFormatContainer, and handleListItem now push the block's direction into context.implicitFormat via stackFormat, so descendants can see the inherited RTL context.

Test plan

  • yarn test:fast (full roosterjs-content-model-dom suite: 2199 passing, +11 new tests)
  • yarn eslint
  • yarn b
  • New end-to-end cases in endToEndTest.ts: LTR table under RTL table, RTL table under LTR table, RTL table under RTL table — all assert the expected justify-self presence/absence
  • New unit tests in directionFormatHandlerTest.ts, handleTableTest.ts, handleFormatContainerTest.ts, handleListItemTest.ts verifying direction propagation through implicitFormat and its restoration after stackFormat

🤖 Generated with Claude Code

JiuqingSong and others added 2 commits May 19, 2026 14:20
An RTL <table> currently always renders with `justify-self: flex-end` to
push it to the right edge of an LTR parent. When the parent context is
already RTL (e.g. an RTL table cell, an RTL <div>/<blockquote>, or an
RTL list item) the table is already aligned correctly by RTL flow, so
the extra `justify-self` causes visual misalignment.

Propagate the current block's direction into context.implicitFormat from
handleTable (cell children), handleFormatContainer, and handleListItem.
The direction format handler now skips `justify-self: flex-end` when
context.implicitFormat.direction is `rtl`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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