# 新主题标题输入框（#reply-title）在 RTL 站点中仍保持 LTR 方向 — 修复仍未生效（2026）

**URL:** https://meta.discourse.org/t/new-topic-title-input-reply-title-remains-ltr-in-rtl-sites-fix-still-not-effective-2026/400490
**Category:** Bug
**Tags:** composer, rtl
**Created:** [2026年四月12日 12:09 UTC](https://meta.discourse.org/t/new-topic-title-input-reply-title-remains-ltr-in-rtl-sites-fix-still-not-effective-2026/400490 "2026-04-12T12:09:54Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Nima1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nima1/32/299628_2.png) [@Nima1](https://meta.discourse.org/u/Nima1)
#### Post date: [2026年四月12日 12:09 UTC](https://meta.discourse.org/t/new-topic-title-input-reply-title-remains-ltr-in-rtl-sites-fix-still-not-effective-2026/400490/1 "2026-04-12T12:09:54Z")

</div>

### 错误描述

在任何从右向左（RTL）的站点上（已在波斯语/法尔西语实例上测试），编辑器中的 **主题标题输入框** 即使整个页面为 RTL 布局，仍保持从左向右（LTR）显示。

- 该输入框设置了 `dir="auto"`（或在某些情况下根本没有 `dir` 属性）。
- 计算后的 `direction` 始终为 **LTR** ，无论设置如何。
- 占位符文本、光标移动和输入方向均不正确，直到输入第一个 RTL 字符（即使如此，行为仍不一致）。

### 复现步骤

1. 将站点设置为 RTL（或使用波斯语区域设置）。
2. 启用“支持混合文本方向”（官方设置）。
3. 打开编辑器（新建主题或回复）。
4. 查看标题字段（`.title-input` 内的 `#reply-title`）。

### 当前行为

输入框渲染为 LTR：

- 文本对齐方式为左对齐。
- 光标和选区行为表现为 LTR。
- 即使对 `direction: rtl`、`text-align: right` 和 `unicode-bidi: embed` 应用了激进的 CSS `!important` 规则，计算后的样式仍显示为 LTR。

 ![image](https://global.discourse-cdn.com/meta/original/4X/c/5/0/c50c489f9235a50582ad67d1f5a70ed5c0d3e9d6.png)

**输入框的 HTML（在检查器中查看）：**

```html
<input aria-label="عنوان موضوع خود را اینجا بنویسید" placeholder="عنوان موضوع خود را اینجا بنویسید" ... id="reply-title" class="ember-text-field ember-view" type="text">

```

**`<input>` 的计算样式（相关部分）：**

- `direction: rtl` 被覆盖或忽略。
- 当字段为空或仅包含中性字符时，字段会回退到 LTR。

### 我已尝试的方法

- 所有标准 CSS 覆盖方案（包括最具体的选择器 + `!important` + `unicode-bidi: embed`）。
- 切换“支持混合文本方向”设置（开启/关闭）。
- 强制刷新并清除缓存。
- 使用 Meta 上推荐的精确规则的主题组件。

以上方法均无法强制输入框从一开始就遵循 RTL 方向。

### 预期行为

标题输入框应像编辑器的其余部分和已处理内容一样表现：

- 在 RTL 站点上默认设置为 `direction: rtl`。
- 正确支持 `dir="auto"`（或在站点为 RTL 时强制设置 `dir="rtl"`）。
- 占位符、光标和文本方向应立即表现为 RTL。

该问题于 2025 年 10 月报告（[https://meta.discourse.org/t/titles-placeholder-in-new-topic-is-not-rtl/385232），并附有“修复待定”的说明。但该错误仍然存在。](https://meta.discourse.org/t/titles-placeholder-in-new-topic-is-not-rtl/385232%EF%BC%89%EF%BC%8C%E5%B9%B6%E9%99%84%E6%9C%89%E2%80%9C%E4%BF%AE%E5%A4%8D%E5%BE%85%E5%AE%9A%E2%80%9D%E7%9A%84%E8%AF%B4%E6%98%8E%E3%80%82%E4%BD%86%E8%AF%A5%E9%94%99%E8%AF%AF%E4%BB%8D%E7%84%B6%E5%AD%98%E5%9C%A8%E3%80%82)

**Discourse 版本：** （请填写您在 /admin 中的确切版本）

**浏览器/操作系统：** （Chrome/Firefox + Windows/macOS/Android — 您正在使用的任何组合）

非常希望此问题能得到修复——这是编辑器中剩余的最明显的 RTL 问题之一。谢谢！

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2026年四月13日 01:23 UTC](https://meta.discourse.org/t/new-topic-title-input-reply-title-remains-ltr-in-rtl-sites-fix-still-not-effective-2026/400490/2 "2026-04-13T01:23:53Z")

</div>

是的，这是一个棘手的问题，无法仅通过 CSS 解决，我们需要修改标记。

具体来说，当字段为空时设置 `direction: auto` 会使其变为 LTR。

> **[3.2.6.4 The dir attribute - HTML Standard](https://html.spec.whatwg.org/multipage/dom.html#the-dir-attribute)**
>
> Living Standard — Last Updated 7 April 2026

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/7/3/d73fe4f41e7e7b408199058c5dc9e9247769d8af.png)

因此，如果输入框为空，方向将显示为 LTR。

我在此处的修复方案是：在这种情况下默认设置为 “rtl”，并在输入第一个字母后立即切换为 auto。

@Osama 能否请你审查并合并？

> <https://github.com/discourse/discourse/pull/39213>
>
> Use the site's direction as the fallback \`dir\` value for mixed-direction
> text fi…elds until the user enters a strong LTR or RTL character.
> 
> This keeps empty and neutral input aligned with the current locale while
> still switching to \`auto\` when the field content provides directionality.

@david 为了干净地测试这一点，我不得不将一个测试辅助函数泄露到我们的代码库中，但我相信这类东西最终会被 tree shake 掉。

---

<div class="post-metadata">

### Author: ![Osama](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/osama/32/98013_2.png) [@Osama](https://meta.discourse.org/u/Osama)
#### Post date: [2026年四月16日 11:00 UTC](https://meta.discourse.org/t/new-topic-title-input-reply-title-remains-ltr-in-rtl-sites-fix-still-not-effective-2026/400490/3 "2026-04-16T11:00:11Z")

</div>

@Nima1 我们已合并此问题的修复方案——感谢您的反馈。

---

<div class="post-metadata">

### Author: ![Osama](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/osama/32/98013_2.png) [@Osama](https://meta.discourse.org/u/Osama)
#### Post date: [2026年四月20日 05:00 UTC](https://meta.discourse.org/t/new-topic-title-input-reply-title-remains-ltr-in-rtl-sites-fix-still-not-effective-2026/400490/4 "2026-04-20T05:00:18Z")

</div>

此主题在 3 天后自动关闭。不再允许新回复。
