Problem/Motivation

Core's htmx:beforeSwap handler in core/misc/htmx/htmx-assets.js drops the promise of the assets a response brings, so htmx:drupal:load fires before those scripts have run.

The behaviors they define never attach to the form that brought them: core's autocomplete, and the ui_icons autocomplete and grid trigger, stay inert until a later form loads.

The component's core/drupal.ajax dependency works around the same bug, for #ajax only.

Found with ui_icons, see #3591899: Add automated functional acceptance testing for Webshare with webship-js (Playwright + Cucumber-js), Drupal Canvas + Drupal CMS support, and MkDocs documentation

Steps to reproduce

1. Enable ui_icons_patterns and open a page layout builder.
2. Insert the "Icon" block and type an icon name in its Config tab. No suggestions show.
3. Select another element, then the Icon block again. Suggestions now show.

Proposed resolution

Wrap Drupal.htmx.addAssets() and attach behaviors on the side panels once its promise resolves, with a @todo to remove it once core waits for the assets.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mogtofu33 created an issue. See original summary.

  • mogtofu33 committed f7a839c4 on 1.0.x
    fix: #3631446 Behaviors miss the scripts a contextual form brings on its...
mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

pdureau’s picture

Status: Fixed » Closed (fixed)