Preview link accidentally closes the media library

Created on 29 July 2020, over 4 years ago
Updated 5 June 2024, 7 months ago

Problem/Motivation

Image is removed from form when using Preview button with Media Library.

Steps to reproduce

  1. Add a mew media item by clicking "Add media"
  2. Upload a new image and see the thumbnail with the Preview link under it
  3. Click Preview link to see previews modal
  4. Close modal - the result is that the image that was once there is now gone.

Screencast:

https://gyazo.com/7327c096ef470e31c6348cac9ad463b5

Proposed resolution

Image should be preserved. Or give the ability to suppress the Preview button in configuration.

Remaining tasks

n/a

User interface changes

If underlying issue cannot be fixed, give us an option to hide the Preview link in configuration.

API changes

n/a

Data model changes

n/a

Release notes snippet

n/a

🐛 Bug report
Status

Fixed

Version

2.0

Component

Media Integration

Created by

🇺🇸United States capellic Austin, Texas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada man-1982

    The patch in #17 functions as expected. It was tested with the following configurations:

    Drupal version: 10.1.6
    PHP version: 8.1.25
    Additionally, the latest development version of the module was used: composer require 'drupal/focal_point:2.x-dev@dev'.

    Suggest to add this patch into main branch.

    Thank you.

  • Status changed to Needs review 9 months ago
  • 🇳🇿New Zealand siramsay

    Switching this back to review, as maybe this is a better solution?

    By using a dialog OpenDialogCommand instead of a modal window, OpenModalDialogCommand the dialog opens on top of the Media window.
    ( https://www.drupal.org/node/1989646 Ajax commands for opening and closing Dialogs and generic Dialog Controller added to core)

    We need to name the new dialog with an ID such as "#focal-point-preview" but this doesn't really matter except we need to pass the argument.

    $response->addCommand(
         - new OpenModalDialogCommand($this->t('Images preview'), $output, $options)
         + new OpenDialogCommand('#focal-point-preview',$this->t('Images preview'), $output, $options)
     );

    I've also added a wrapper to the original image, so the size is known before the image is loaded. This fixes the modal so it does centre strangely on first load.

    <div class="focal-point-original-image">{{ original_image }}</div>

    .focal-point-original-image {
      height: 500px;
    }
    

  • First commit to issue fork.
  • Merge request !23Resolve #3162210 "Preview link accidentally" → (Merged) created by dwisnousky
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.2 & MySQL 8
    last update 9 months ago
    158 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.2 & MySQL 8
    last update 9 months ago
    Patch Failed to Apply
  • 🇺🇸United States dwisnousky

    I can verify that what @siramsay suggests works flawlessly

  • Status changed to RTBC 8 months ago
  • 🇺🇸United States dasginganinja Bethlehem, PA

    I've tested the code by @dwisnousky in the MR as well as the patch in #33.

    I can confirm the preview modal shows over the existing modal and does not close it out.
    Closing out the preview modal allows the modal behind it to be selected again and doesn't lose the data changes that were present.

    Tested with
    - Field Group @ 3.4
    - Gin @ 3.0RC10
    - Drupal 10.2.5

  • 🇮🇳India rajeshreeputra Pune

    Setting the height to 500px results in blank or white space appearing below the image when using smaller image styles in preview, hence removing.

    .focal-point-original-image {
      height: 500px;
    }
    
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.2 & MySQL 8
    last update 8 months ago
    159 pass
  • Pipeline finished with Skipped
    8 months ago
    #165282
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.2 & MySQL 8
    last update 8 months ago
    159 pass
  • 🇮🇳India rajeshreeputra Pune

    Merged, release to follow shortly.

  • Status changed to RTBC 7 months ago
  • 🇺🇸United States DamienMcKenna NH, USA

    This one was accidentally reopened by the commit bot.

  • Status changed to Fixed 7 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024