Skip to content

Align left-justified layouts to the start edge in RTL - #263

Merged
MaggieCabrera merged 3 commits into
trunkfrom
fix/261-rtl-start-alignment
Nov 30, 2026
Merged

MaggieCabrera merged 3 commits into
trunkfrom
fix/261-rtl-start-alignment

Conversation

@MaggieCabrera

@MaggieCabrera MaggieCabrera commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #261. Alternative to #262, which adds CSS that a user can't easily override in the editor. This one changes only the block markup.

Description

In RTL, the main column of the sidebar templates and the "read more" link in the archive and search patterns stayed on the left. Core writes a constrained layout's "left" justification as physical margins, so it doesn't follow the text direction.

  • Sidebar templates: the column's justification is right when is_rtl(), left otherwise. LTR output is unchanged.
  • Archive Standard, Archive Compact, Archive Lead and Search: the excerpt and read more group is now a Stack, which follows the text direction.
  • A sidebar template that's already customized keeps the side it was saved with.

Testing Instructions

  1. Set the site language to an RTL one, such as Persian.
  2. Open a page that uses the Pages Sidebar template. The title and content sit against the right edge of the main column.
  3. Open a search results page. The "read more" links sit on the right. In LTR, both look the same as on trunk.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Fable 5.2
Used for: Finding the cause, writing the change and measuring it against trunk in both directions; reviewed by me.

🤖 Generated with Claude Code

Core writes a constrained layout's "left" justification as physical
margins, so in RTL the content stays on the left.

- Sidebar templates: the main column's justification follows is_rtl().
- Archive and search patterns: the excerpt and read more group is a
  Stack, whose alignment follows the text direction.

Fixes #261.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions github-actions Bot added the [Area] Patterns Issues or PRs that touch the theme's block patterns. label Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org>
Co-authored-by: juanfra <juanfra@git.wordpress.org>
Co-authored-by: Goudarz <goudarz@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@juanfra juanfra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Nice, I believe this is a better approach than the CSS, and it's testing well for me.

One thing I noticed while testing is that is_rtl() follows the logged-in user profile language in the editor, and not the site. Edge case and not a blocker for this, but it's probably worth investigating more and reporting where's necessary.

In the editors is_rtl() follows the current user's language, so an
editor whose profile reads the other way would save the wrong side into
the template.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions github-actions Bot added the [Area] Theme Functions Issues or PRs that touch functions.php. label Nov 30, 2026
@github-actions github-actions Bot removed the [Area] Theme Functions Issues or PRs that touch functions.php. label Nov 30, 2026
@MaggieCabrera

Copy link
Copy Markdown
Contributor Author

One thing I noticed while testing is that is_rtl() follows the logged-in user profile language in the editor, and not the site. Edge case and not a blocker for this, but it's probably worth investigating more and reporting where's necessary.

Well, that does seem like an edge case, but if someone has a LTR setting and they are an admin, it seems consistent that it behaves like a LTR site

@MaggieCabrera
MaggieCabrera merged commit e68cd9f into trunk Nov 30, 2026
5 checks passed
@MaggieCabrera
MaggieCabrera deleted the fix/261-rtl-start-alignment branch November 30, 2026 15:35
MaggieCabrera added a commit to MaggieCabrera/wordpress-develop that referenced this pull request Nov 30, 2026
In RTL, the main column of the sidebar templates and the read more link in the archive and search patterns stayed on the left, because core writes a constrained layout's left justification as physical margins. They now follow the text direction, and LTR looks the same as before.

Synced from WordPress/ipsum#263.

See #66817.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Area] Patterns Issues or PRs that touch the theme's block patterns.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pages Sidebar keeps the title and content on the left in RTL

2 participants