Skip to content

修复 sandbox iframe 使用 display: none 导致的问题#1478

Open
cyfung1031 wants to merge 1 commit into
mainfrom
fix/sandbox-iframe-hidden/001
Open

修复 sandbox iframe 使用 display: none 导致的问题#1478
cyfung1031 wants to merge 1 commit into
mainfrom
fix/sandbox-iframe-hidden/001

Conversation

@cyfung1031
Copy link
Copy Markdown
Collaborator

@cyfung1031 cyfung1031 commented May 28, 2026

描述

本次修改调整了 sandbox iframe 的隐藏方式,避免直接使用 display: none

之前 iframe 通过内联样式 display: none 隐藏,可能会影响 sandbox 页面的正常加载或通信行为。现在改为使用 CSS 类将 iframe 缩小到 1px、设置透明、禁用交互并裁剪显示区域,在视觉上隐藏 iframe 的同时,仍保留其正常存在于页面中的行为。

同时为 iframe 增加了 aria-hidden="true"tabindex="-1",避免其被辅助技术读取或通过键盘聚焦。

主要变更

  • 移除 iframe 上的 style="display: none"
  • 新增 .sandbox-iframe 样式用于视觉隐藏 iframe
  • 为 iframe 添加 aria-hidden="true"tabindex="-1"
  • 保持 sandbox iframe 可正常加载和运行

测试

  • E2E 确认 sandbox iframe 能正常加载 & 相关脚本执行 / 通信功能正常 (window_message_test)

@cyfung1031 cyfung1031 changed the title Hide sandbox iframe without using display none 修复 sandbox iframe 使用 display: none 导致的问题 May 28, 2026
@cyfung1031 cyfung1031 marked this pull request as ready for review May 28, 2026 16:32
@CodFrm
Copy link
Copy Markdown
Member

CodFrm commented May 29, 2026

"可能会影响 sandbox 页面的正常加载或通信行为" 这个是哪里的结论,实际上有这个问题?会出现?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants