# 在移动端视图中，在各种模态框中添加用户非常困难

**URL:** <https://meta.discourse.org/t/add-user-to-list-modal-often-appears-above-the-mobile-viewport-sceen/400974>\
**Category:** Bug\
**Tags:** mobile\
**Created:** [2026年四月19日 02:55 UTC](https://meta.discourse.org/t/add-user-to-list-modal-often-appears-above-the-mobile-viewport-sceen/400974 "2026-04-19T02:55:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)\
**Post date:** [2026年四月19日 02:55 UTC](https://meta.discourse.org/t/add-user-to-list-modal-often-appears-above-the-mobile-viewport-sceen/400974/1 "2026-04-19T02:55:48Z")

</div>

### 🐛 概述

移动端视图下，用于添加用户的下拉列表模态框经常出现在屏幕可视区域之外，导致尝试向下滑动查看时操作失败。

我在安全模式下复现此问题的一些场景包括：

- 在群组页面将用户添加到群组
- 将主题或帖子分配给用户（例如：从主题扳手菜单或帖子管理扳手菜单）
- 邀请另一位用户加入私信（PM）
- 将用户添加到忽略列表 `/my/preferences/users`（静音功能正常，因为下拉菜单没有模态框）

偶尔，在尝试轻轻向下滑动几次后，我可以使模态框保持在可视区域内，但这非常不稳定，且经常直接关闭。另外值得注意的是，我使用的是大屏幕手机（iPhone 15 Pro Max），因此该问题在更小的移动设备型号上可能更为严重。

### 🚶‍♀️ 复现步骤

以下是尝试填写下拉列表以将用户添加到群组时失败的一个示例：

1. 以管理员身份进入群组页面，点击“+ 添加用户”按钮
2. 在屏幕底部看到带有搜索字段的模态框
3. 点击搜索字段输入内容，此时模态框会移至视口上方
4. 尝试向下拖动模态框以便在字段中输入
5. 失败 - 模态框自动关闭并返回到群组成员页面。

 ![IMG5146](https://global.discourse-cdn.com/meta/original/4X/9/b/b/9bba042f8c7291c952080921c432a5162ff397f1.jpeg)  
 ![IMG5147](https://global.discourse-cdn.com/meta/original/4X/7/5/f/75f635f985816e0cc3dec91c7994fa68d034c3d0.jpeg)

### ✅ 预期结果

模态框应保持在可视区域内。请注意，从帖子管理菜单更改帖子所有权的类似模态框按预期工作：

 ![IMG5151](https://global.discourse-cdn.com/meta/original/4X/6/2/3/623a54ad56503ce73dbac999be0a9e0f9e609d74.jpeg)

### ❌ 实际结果

如上所述：由于模态框在视口中位置过高，导致用户搜索输入字段不可见。

### 📚 附加信息

- 我使用的是 iPhone 15 Pro Max，并在安全模式下使用最新的 Safari、Chrome 和 Firefox（以及 PWA）复现了上述问题。但在 iPad 上（无论是横屏还是竖屏）未复现。尚未确认 Android 移动端的情况。
- 在桌面浏览器开发工具中使用移动模式无法复现此问题；我只能在移动设备上复现。
- 我不确定这是 Discourse 的问题还是 iOS 的问题（我倾向于认为是 Discourse，因为更改帖子所有权的模态框似乎按预期工作）。

---

<div class="post-metadata">

**Author:** ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)\
**Post date:** [2026年四月20日 20:50 UTC](https://meta.discourse.org/t/add-user-to-list-modal-often-appears-above-the-mobile-viewport-sceen/400974/2 "2026-04-20T20:50:37Z")

</div>

是的，这确实是个烦人的行为！我这边有一个修复方案正在运行：

> <https://github.com/discourse/discourse/pull/39382>
>
> When we have a dropdown with an input inside of a modal, iOS will attempt to pos…ition the input and ends up shifting up the entire modal to be unreachable. 
> 
> This change avoids the issue by: 
> 
> 1. capturing the current scroll position
> 2. set \`window.scrollTo(0, lockedScrollY)\` to undo iOS' scroll attempt 
> 3. on close, resets to the \`lockedScrollY\` position 
> 
> Before: 
> 
> https://github.com/user-attachments/assets/5e2fe34a-bb24-49c4-849a-d910150d389b
> 
> 
> After: 
> 
> https://github.com/user-attachments/assets/70c51e3f-36d9-4eca-93cf-fd43e4b29878

@j.jaffeux 你在模态框/菜单方面做了很多工作，对此有什么看法吗？

---

<div class="post-metadata">

**Author:** ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)\
**Post date:** [2026年四月21日 12:48 UTC](https://meta.discourse.org/t/add-user-to-list-modal-often-appears-above-the-mobile-viewport-sceen/400974/4 "2026-04-21T12:48:48Z")

</div>

已合并上述更改，希望这能在不产生副作用的情况下改善现状。固定模态框多年来在苹果设备上一直难以支持，因此我们可能还需要进行一些额外的调整。

---

<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年四月22日 05:08 UTC](https://meta.discourse.org/t/add-user-to-list-modal-often-appears-above-the-mobile-viewport-sceen/400974/5 "2026-04-22T05:08:47Z")

</div>


