Skip to content

Block Editor: Icon picker never initialises in repeater items added inside the editor canvas #2369

Description

@Misplon

What happens

In the block editor, add a SiteOrigin Hero block, add a frame, add a button inside it, click Choose Icon. Nothing opens. Same with the Price Table block: add a column, add a feature, click Choose Icon. The icon field inside the newly added repeater item never gets data-initialized, so its click handler is never bound.

Reproduced on the 1.74.3 release build and on the published 1.74.2, both in a fresh WordPress Playground, WP 7.1. Not a regression, but the 1.74.3 changelog line "Block Editor: Fixed the icon picker not initializing in newly added or copied repeater items" claims this is fixed and it is not. That line came from commit 30db145, Step 1 of the #2334 Price Table branch, which had no issue of its own.

Why

Three things, each verified live in the editor canvas iframe:

  1. base/inc/fields/js/icon-field.js binds sowsetupformfield to the icon field only when window.top === window.self. Inside the canvas iframe the binding is skipped. The iframe document's sowsetupformfield handlers are media, tinymce and location only. So the 30db145 change, which adds the icon field to repeaterImmediateSetupFieldSelector in base/js/admin.js and fires sowsetupformfield, cannot reach the icon field in the block editor.
  2. The MutationObserver in icon-field.js that is meant to cover iframes is not running: a bare .siteorigin-widget-field-type-icon element appended to the iframe body stays uninitialised.
  3. triggerRepeaterFieldSetup() in admin.js fires sowrepeaterfieldsadded on the iframe's document. compat/block-editor/widget-block.js listens for it on the top document under a per-block namespace. The event never crosses, so the block never re-sends the sowbBlockFormInit postMessage. Posting that message by hand initialises the new icon fields immediately and the picker opens.

Fix

Make the repeater-added signal reach the block in the canvas case, so the existing sowbBlockFormInit path re-runs ensureIconFieldsInitialized(). Either fire sowrepeaterfieldsadded on the top document as well when window.top !== window.self, or have widget-block.js listen on the canvas document. Cover it with a Playground e2e: Hero, add frame, add button, Choose Icon opens.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions