fix: #3633891 Focal Point does not work on a generated image

Closes https://www.drupal.org/i/3633891

What changed

  • Core's HTMX integration attaches behaviors to swapped markup before the scripts that swap brought have loaded. The first generated image is the first time the image widget is on the page, so Focal Point's script arrives with it and its focalPointIndicator behavior never runs: the crosshair stays in the top left and the "Focal point" field shows.
  • js/ai-media.admin.js now watches for scripts added to the page; when one has loaded it attaches behaviors to the AI Media form again. once() keeps every behavior to one run, so nothing attaches twice.
  • No change on a site without Focal Point: no script is added, nothing re-attaches.

Independent of !30 (merged), !31 (merged) and !32 (merged) (based on 1.0.x).

Testing

  • Varbase 11 with Focal Point, Gin: generated an image in the Media Library; the crosshair starts in the centre (50,50) and the Focal point field is hidden, as on an uploaded image. Before: crosshair top left, field shown.
  • eslint (core config) and phpcs clean.

Screenshots

Generated image in the Media Library with the Focal Point crosshair in the centre

AI-Generated: Yes

Checkpoints

  • Issue linked
  • Coding standards (eslint, phpcs)
  • Tested manually with Focal Point in Gin
  • Tested on a site without Focal Point
  • Reviewed by a human
  • Code review by maintainers

🤖 Generated with Claude Code

Edited by Rajab Natshah

Merge request reports

Loading
Loading