Links/forms in ACF block previews navigate the iframed editor canvas on WP 7.1 (crashes editor when cross-origin)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- Nửa ngày
- Mức phù hợp với người mới
- 52/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, php, wordpress
- Lĩnh vực
- frontend
Hướng nghiên cứu
Start with the existing "Navigation prevented for" handling in the acf-pro-blocks scripts, and look at how .acf-block-preview is rendered. Reproduce by adding a block whose render output contains an a with an external href, then clicking it in the editor. Done means clicks on non-hash a[href] and form submits inside the preview no longer navigate the canvas, while block selection still works.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Environment
WordPress 7.1.3 (post editor canvas always iframed, shouldIframe: true)
ACF PRO 6.8.10
Blocks registered via block.json with no block version declared (so V3 by default since 6.8.9), "acf": { "mode": "edit" }, server-rendered with render_callback
Steps to reproduce
Register an ACF block whose render output contains an (any non-# link).
Add it to a post in the block editor on WP 7.1. The preview renders, which is the V3 default.
Click the link in the preview.
Expected
Clicking a link in a block preview selects the block. It doesn’t navigate.
Actual
The click navigates the editor-canvas iframe to the link’s URL. Core’s iframe only intercepts #hash links (interceptLinkClicks in block-editor).
Same-origin link: the frontend page silently replaces the editor canvas.
Cross-origin link: the canvas window becomes cross-origin. The next time a block unmounts or re-renders, the editor crashes with “The editor has encountered an unexpected error”:
SecurityError: Failed to read a named property 'removeEventListener' from 'Window':
Blocked a frame with origin "https://example.com" from accessing a cross-origin frame.
at wp-includes/js/dist/compose.min.js (useRefEffect cleanup)
at $e / Bt (useMergeRefs cleanup)
A
in a preview, such as Gravity Forms, navigates the canvas on submit in the same way.Why this is new
Before 7.1, V2 blocks disabled the iframe, and mode: edit showed the field form rather than the rendered preview. On WP 7.1 with ACF 6.8.9+, these blocks are V3 and show live, clickable server HTML inside an iframe that core doesn’t guard. ACF already prevents navigation for inline-editing elements (Navigation prevented for … in acf-pro-blocks), but not for the rest of the preview.
Suggested fix
Inside .acf-block-preview, preventDefault() capture-phase click events on non-# a[href] and submit events on forms, while leaving propagation alone so block selection still works.
Workaround we’re using
A small mu-plugin that does exactly that, via an inline script on enqueue_block_assets when is_admin() is true.
- Ngôn ngữ chính
- PHP
- Star
- 947
- Fork
- 198
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của AdvancedCustomFields/acf
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
AdvancedCustomFields/acf#1056 ·
-
PHP 8.5: "Using null as an array offset" deprecation in ACF_Data::is() when rendering a block with empty data (local-meta.php is_request)Có thể đã có người làm @faisalahammad đã nhận 30 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
AdvancedCustomFields/acf#1044 ·
-
is_preview was called incorrectly notice on every early get_field() since 6.8.10 (acf_revisions::acf_validate_post_id)Có thể đã có người làm @faisalahammad đã nhận 30 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
AdvancedCustomFields/acf#1041 · 1 bình luận ·
-
True / False ACF control bug on RTL layoutsCó thể đã có người làm @elicohenator đã nhận 53 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
AdvancedCustomFields/acf#1038 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
AdvancedCustomFields/acf#1034 · 3 bình luận ·
Tất cả issue của AdvancedCustomFields/acf
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
benjaminkott/bootstrap_package#1675 ·
-
sync-en
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Sync EN] Formatting improvements to "Large Objects (LOBs)" docs (#6056)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởsync-en
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày