# iOS Markdown 编辑器在第二次选中文本时卡死

**URL:** https://meta.discourse.org/t/ios-markdown-composer-editor-freezes-when-selecting-text-a-second-time/407258
**Category:** Bug
**Tags:** composer, ios
**Created:** [2026年七月10日 11:50 UTC](https://meta.discourse.org/t/ios-markdown-composer-editor-freezes-when-selecting-text-a-second-time/407258 "2026-07-10T11:50:36Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ethsim2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ethsim2/32/522255_2.png) [@Ethsim2](https://meta.discourse.org/u/Ethsim2)
#### Post date: [2026年七月10日 11:50 UTC](https://meta.discourse.org/t/ios-markdown-composer-editor-freezes-when-selecting-text-a-second-time/407258/1 "2026-07-10T11:50:37Z")

</div>

我在 iOS 上的 Discourse Markdown 编辑器中遇到了一个可复现的文本选择问题。

这与我之前报告的 `/upcoming-events` 问题无关。我在早期的重建后首次注意到这种编辑器行为，并且在我最近两次重建后该问题依然存在。

### 测试版本

- `v2026.7.0-latest +188`
- `v2026.7.0-latest +195`

测试时，`+196` 版本已可用，但其中唯一的额外提交似乎与编辑器无关。

### 复现步骤

1. 在 Markdown 模式下打开新建话题或回复编辑器。
2. 输入或粘贴多行文本。
3. 长按并选择部分文本。
4. 第一次选择正常工作。
5. 点击其他地方以清除选择。
6. 再次长按文本并尝试进行另一次选择。

### 预期结果

每次选择时，iOS 文本选择菜单和句柄都应正常显示，包括在适用时提供 **全选** 选项。

### 实际结果

编辑器首次打开时，选择功能正常工作。

清除第一次选择后，再次尝试选择文本会导致编辑器或文本选择界面无响应。我无法再可靠地选择文本、移动选择句柄或使用 **全选** 。

### 已完成的测试

- 在 `v2026.7.0-latest +188` 上可复现
- 重建至 `v2026.7.0-latest +195` 后仍可复现
- 在 Discourse 安全模式下可复现
- 重新测试前已移除损坏或过时的主题组件
- 第一次选择始终有效；问题始于取消选择并再次尝试选择时

### 环境

- 客户端：iOS
- 界面：已安装的 PWA 或 Safari
- 编辑器：Markdown 模式
- Discourse 安全模式：可复现
- 当前安装的 Discourse 版本：`v2026.7.0-latest +195`

如有需要，我可以提供 iOS 版本、设备型号和屏幕录制视频。

---

<div class="post-metadata">

### Author: ![tannerabread](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tannerabread/32/526153_2.png) [@tannerabread](https://meta.discourse.org/u/tannerabread)
#### Post date: [2026年七月10日 16:27 UTC](https://meta.discourse.org/t/ios-markdown-composer-editor-freezes-when-selecting-text-a-second-time/407258/4 "2026-07-10T16:27:07Z")

</div>

你好 @Ethsim2

我认为这与我上周为了缓解 WebKit 和 iOS（尤其是 iPad）带来的一些 UI 怪癖而所做的更改有关。

> <https://github.com/discourse/discourse/pull/41366>
>
> There are quite a few issues with the composer positioning on iOS devices, espec…ially on iPad because that requests the desktop site and gives a desktop-looking user agent. The main issue is that the cursor drops 1-3 lines when scrolling the background behind the composer.
> 
> This utilizes the existing body-scroll-lock library to lock the scroll of the background when the composer is open on iOS devices. This fix adds extra logic to body-scroll-lock to account for 'iPad' when the user agent is requesting the desktop site. Then it wires up the lock/unlock logic to the composer position code.
> 
> This effectively locks the background while the composer is focused on iOS devices, which prevents the cursor from dropping. It also mitigates quite a few other UI quirks that occur with background scrolling.
> 
> The change to select-kit-collection.gjs was defense against a potential future issue where the select-kit collection could be the target element and would therefore throw in the check.

我今天休息，周一一上班就会优先调查此事。如果你能告知你使用的设备型号，将很有帮助。

---

<div class="post-metadata">

### Author: ![Ethsim2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ethsim2/32/522255_2.png) [@Ethsim2](https://meta.discourse.org/u/Ethsim2)
#### Post date: [2026年七月10日 17:08 UTC](https://meta.discourse.org/t/ios-markdown-composer-editor-freezes-when-selecting-text-a-second-time/407258/5 "2026-07-10T17:08:34Z")

</div>

谢谢——我在一部运行 **iOS 26.5** 的 **iPhone 16 Pro（型号 MYNQ3QN/A）** 上进行了测试。

我在以下两种环境中都能复现该问题：

- 已安装的 Discourse PWA
- Safari

两种情况下的表现相同：第一次文本选择正常，但在取消选择后，第二次尝试调整选择范围会导致选择界面无响应。

如果需要，我可以提供屏幕录制视频。

---

<div class="post-metadata">

### Author: ![tannerabread](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tannerabread/32/526153_2.png) [@tannerabread](https://meta.discourse.org/u/tannerabread)
#### Post date: [2026年七月14日 21:06 UTC](https://meta.discourse.org/t/ios-markdown-composer-editor-freezes-when-selecting-text-a-second-time/407258/6 "2026-07-14T21:06:49Z")

</div>

嘿 @Ethsim2 我刚刚合并了一个修复此问题的补丁，很快就会可用。

> <https://github.com/discourse/discourse/pull/41711>
>
> PR #41366 introduced a regression on iOS where text-selection gestures in the co…mposer would get canceled. The scroll-lock added there routes composer touchmove events through body-scroll-lock, which calls \`preventDefault\` at scroll boundaries -- and a short textarea is always at its boundary -- so iOS never got a chance to handle the selection-handle drag.
> 
> Add a capture-phase touchmove listener on the editor that stops propagation when the editor has a selection, so the event never reaches body-scroll-lock's handlers and iOS handles the gesture natively.
> 
> \[Meta Topic\](https://meta.discourse.org/t/ios-markdown-composer-editor-freezes-when-selecting-text-a-second-time/407258)
