Problem/Motivation

After Generate in the Media Library dialog opened from a node form, the node form's Save stops working. It posts ?ajax_form=1 and shows "Oops, something went wrong." Edits are lost. Picking an existing item without Generate keeps Save working.

Cause: the Generate request is htmx, so core does not make ids unique, and the library's "Insert selected" renders as a plain #edit-submit whose ajax settings bind the node form's Save.

Steps to reproduce

  1. Open a node add form with a media field.
  2. Click Add media, then Generate with AI.
  3. Click Generate, then Insert selected.
  4. Click Save.

Proposed resolution

Render the htmx response with unique ids, as an AJAX request would, or scope the ajax settings it adds. Add a functional test.

Remaining tasks

  • ✅ File an issue
  • ❌ Addition/Change/Update/Fix
  • ❌ Testing to ensure no regression
  • ➖ Automated unit/functional testing coverage
  • ➖ Developer Documentation support
  • ➖ User Guide Documentation support
  • ➖ UX/UI designer responsibilities
  • ➖ Accessibility and Readability
  • ❌ Reviewed by a human
  • ❌ Code review by maintainers
  • ❌ Full testing and approval
  • ❌ Credit contributors
  • ❌ Review with the product owner
  • ✅ Update Release Notes
  • ✅ Release

User interface changes

  • Before (1.0.x): Save after Generate and Insert selected fails with "Oops, something went wrong".
     Save after Generate and Insert selected fails with "Oops, something went wrong".
  • After: the article saves with the generated image.
     the article saves with the generated image.

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • N/A

AI-Generated: Yes

Issue fork ai_media-3634856

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

rajab natshah created an issue. See original summary.

rajab natshah’s picture

Issue summary: View changes
StatusFileSize
new58.53 KB
new83.48 KB

  • rajab natshah committed e29c7500 on 1.0.x
    fix: #3634856 Keep the host form's Save working after Generate in the...
rajab natshah’s picture

Issue summary: View changes
Status: Active » Fixed
Issue tags: +ai_media-1.0.0-rc1

✅ Released ai_media-1.0.0-rc1

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.