Problem/Motivation

On adding new media from media library modal, preview link generates ajax error when clicked after choosing a focus point on image.
After investigations, the problem is located in focal_point.js:

// Update the ajax binding to reflect the new preview link href value.
    Drupal.ajax.instances.forEach(function (instance, index) {
      if (instance && $(instance.element).data("selector") === dataSelector) {
        const href = $(instance.selector).attr("href"); // Here instance.selector is always null.
        Drupal.ajax.instances[index].url = href;
        Drupal.ajax.instances[index].options.url = href;
      }
    });

Proposed resolution

Use the correct selector.

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

    b.khouy created an issue. See original summary.

    b.khouy’s picture

    StatusFileSize
    new626 bytes
    b.khouy’s picture

    Issue summary: View changes
    b.khouy’s picture

    Title: Preview ajax error on adding new media in media library modal » Preview link ajax error on adding new media in media library modal
    b.khouy’s picture

    Status: Active » Needs review
    alfattal’s picture

    Priority: Normal » Major
    Status: Needs review » Needs work

    @b.khouy I have applied the patch in #2 and it didn't seem to make any difference. The AJAX error still persists and it's preventing the media from being saved.

    alfattal’s picture

    Priority: Major » Critical

    I'm unable to use the module after upgrading to the latest version (2.1.1) as it keeps throwing the AJAX error even without clicking on the Preview link. I had to downgrade to version (2.1.0) to resolve the issue. Hence, I'm tagging this issue as Critical.

    dave reid’s picture

    alfattal’s picture

    @dave reid I can confirm that the patch in #3462165 resolves this issue.