open-design/apps/web
zqyaym b22c7713db
fix(web): prevent preview iframe from stealing focus on load (#2792)
* Fix preview iframe focus stealing

* Fix preview focus guard for URL-loaded HTML previews

Focus guard was only injected via the srcdoc path, but the default
URL-load path bypasses buildSrcdoc entirely. Add htmlNeedsFocusGuard
detection so focus-stealing HTML is routed through srcdoc where the
guard can suppress window.focus/element.focus calls.

* Widen focus guard detector to cover all .focus() call patterns

The previous regex only matched window.focus() and document.focus(),
missing document.body.focus(), querySelector().focus(), and other
chained focus calls. Broaden to match any `.focus(` so the default
URL-loaded preview path is forced to srcDoc for all focus-stealing HTML.

* Conservatively force srcDoc for HTML with external script references

When the HTML contains <script src=...>, we cannot inspect the linked
file for focus-stealing calls. Force the srcDoc path so the focus guard
intercepts any .focus() calls from external scripts.

---------

Co-authored-by: JoeyZhu <15500388+acthenknow@user.noreply.gitee.com>
2026-05-24 14:37:08 +00:00
..
app feat(observability): web lifecycle telemetry + stable installationId migration (#2527) 2026-05-21 15:37:48 +08:00
public chore(assets): optically center title bar icon inner mark (#2401) (#2439) 2026-05-23 11:46:49 +08:00
sidecar Enable LAN web dev access (#1947) 2026-05-19 17:50:50 +08:00
src fix(web): prevent preview iframe from stealing focus on load (#2792) 2026-05-24 14:37:08 +00:00
tests fix(web): prevent preview iframe from stealing focus on load (#2792) 2026-05-24 14:37:08 +00:00
next-env.d.ts feat(media): port generation workflow onto main (#12) 2026-04-30 22:44:00 +08:00
next.config.ts Merge origin/main into release/v0.8.0 2026-05-23 12:17:18 +08:00
package.json feat(web): enable Next.js Turbopack for the web dev server (#2798) 2026-05-23 15:09:46 +00:00
postcss.config.mjs feat(web): Add Tailwind foundation (#1388) 2026-05-12 21:48:16 +08:00
tsconfig.json chore: enforce test directory conventions (#496) 2026-05-05 15:34:22 +08:00
tsconfig.sidecar.json Add mac packaged runtime and beta release flow (#170) 2026-04-30 20:25:49 +08:00
vitest.config.ts test(e2e): gate beta packaged runtime (#637) 2026-05-06 17:44:29 +08:00