[P0][UI] Modal 组件缺少 centered 属性导致弹窗偏移/裁剪 #1319

Closed
opened 2026-08-09 13:47:55 +08:00 by xiaoxia · 1 comment
Owner

问题描述

用户打开弹窗(如AI配音弹窗)时,如果页面已滚动过一定距离,弹窗会向左或向上偏移,导致左侧内容被裁剪、关闭按钮消失。刷新浏览器后恢复正常。

根因分析

apps/web/src/components/ui/Modal.tsx 封装 Ant Design Modal 时未设置 centered 属性。Ant Design Modal 默认使用 top: 100px 定位,当 .xx-app-content 有内部滚动时,打开 Modal 会触发 body 的 overflow: hidden + padding-right 补偿滚动条宽度。由于页面使用嵌套滚动容器,body 的实际滚动状态和 Modal 的 scroll listener 可能产生竞态,导致 Modal wrap 的 left 计算偏移。

影响范围

全局所有使用 Modal 组件的页面

修复方案

在 Modal.tsx 封装组件中默认添加 centered=true

涉及文件

  • apps/web/src/components/ui/Modal.tsx

优先级

P0 - 修复难度低(改1行代码)

## 问题描述 用户打开弹窗(如AI配音弹窗)时,如果页面已滚动过一定距离,弹窗会向左或向上偏移,导致左侧内容被裁剪、关闭按钮消失。刷新浏览器后恢复正常。 ## 根因分析 apps/web/src/components/ui/Modal.tsx 封装 Ant Design Modal 时未设置 centered 属性。Ant Design Modal 默认使用 top: 100px 定位,当 .xx-app-content 有内部滚动时,打开 Modal 会触发 body 的 overflow: hidden + padding-right 补偿滚动条宽度。由于页面使用嵌套滚动容器,body 的实际滚动状态和 Modal 的 scroll listener 可能产生竞态,导致 Modal wrap 的 left 计算偏移。 ## 影响范围 全局所有使用 Modal 组件的页面 ## 修复方案 在 Modal.tsx 封装组件中默认添加 centered=true ## 涉及文件 - apps/web/src/components/ui/Modal.tsx ## 优先级 P0 - 修复难度低(改1行代码)
xiaoxia added the bugfrontendP0 labels 2026-08-09 13:47:55 +08:00
Author
Owner

代码已核实,修复正确。

Modal.tsx 改动

  • 解构参数增加 centered = true 默认值
  • 传递给 AntModal: <AntModal centered={centered} ...>
  • 所有使用 Modal 组件的弹窗默认居中,且允许单个弹窗覆盖

PR #1325 已提交,CI 跑完后自动合并。

✅ 代码已核实,修复正确。 **Modal.tsx 改动**: - 解构参数增加 `centered = true` 默认值 - 传递给 AntModal: `<AntModal centered={centered} ...>` - 所有使用 Modal 组件的弹窗默认居中,且允许单个弹窗覆盖 PR #1325 已提交,CI 跑完后自动合并。
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: xiaoxia/xiaoxia-saas#1319