Make WordPress Core

Changeset 59187


Ignore:
Timestamp:
10/07/2024 02:47:18 AM (2 months ago)
Author:
peterwilsoncc
Message:

Media: Hide "copied" tooltip once another URL is copied to the clipboard.

On the media grid view, hide the copied tooltip when a subsequent URL is copied to the clipboard. This prevents tooltips from remaining displayed if a user copies multiple URLs within a three second period.

Props antpb, debarghyabanerjee, jayadevankbh, sabernhardt.
Fixes #60082.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/media.js

    r57231 r59187  
    145145            $mediaGridWrap             = $( '#wp-media-grid' ),
    146146            copyAttachmentURLClipboard = new ClipboardJS( '.copy-attachment-url.media-library' ),
    147             copyAttachmentURLSuccessTimeout;
     147            copyAttachmentURLSuccessTimeout,
     148            previousSuccessElement = null;
    148149
    149150        // Opens a manage media frame into the grid.
     
    225226            event.clearSelection();
    226227
     228            // Checking if the previousSuccessElement is present, adding the hidden class to it.
     229            if ( previousSuccessElement ) {
     230                previousSuccessElement.addClass( 'hidden' );
     231            }
     232
    227233            // Show success visual feedback.
    228234            clearTimeout( copyAttachmentURLSuccessTimeout );
     
    232238            copyAttachmentURLSuccessTimeout = setTimeout( function() {
    233239                successElement.addClass( 'hidden' );
     240                // No need to store the previous success element further.
     241                previousSuccessElement = null;
    234242            }, 3000 );
     243
     244            previousSuccessElement = successElement;
    235245
    236246            // Handle success audible feedback.
Note: See TracChangeset for help on using the changeset viewer.