diff options
author | Peter Wilson <peterwilsoncc@git.wordpress.org> | 2024-10-07 02:47:18 +0000 |
---|---|---|
committer | Peter Wilson <peterwilsoncc@git.wordpress.org> | 2024-10-07 02:47:18 +0000 |
commit | 90d242939d030a057c6a0719af415ec336d379e2 (patch) | |
tree | bef94ef8bd9aeafed2cea809dbd86a9f959b67b4 /src/js | |
parent | 023d3c4b3dfdcb59bb235d79697a6d55698719b8 (diff) | |
download | wordpress-90d242939d030a057c6a0719af415ec336d379e2.tar.gz wordpress-90d242939d030a057c6a0719af415ec336d379e2.zip |
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.
git-svn-id: https://develop.svn.wordpress.org/trunk@59187 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/_enqueues/admin/media.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/js/_enqueues/admin/media.js b/src/js/_enqueues/admin/media.js index ddc8a6c933..db61220b50 100644 --- a/src/js/_enqueues/admin/media.js +++ b/src/js/_enqueues/admin/media.js @@ -144,7 +144,8 @@ var settings, $mediaGridWrap = $( '#wp-media-grid' ), copyAttachmentURLClipboard = new ClipboardJS( '.copy-attachment-url.media-library' ), - copyAttachmentURLSuccessTimeout; + copyAttachmentURLSuccessTimeout, + previousSuccessElement = null; // Opens a manage media frame into the grid. if ( $mediaGridWrap.length && window.wp && window.wp.media ) { @@ -224,6 +225,11 @@ // Clear the selection and move focus back to the trigger. event.clearSelection(); + // Checking if the previousSuccessElement is present, adding the hidden class to it. + if ( previousSuccessElement ) { + previousSuccessElement.addClass( 'hidden' ); + } + // Show success visual feedback. clearTimeout( copyAttachmentURLSuccessTimeout ); successElement.removeClass( 'hidden' ); @@ -231,8 +237,12 @@ // Hide success visual feedback after 3 seconds since last success and unfocus the trigger. copyAttachmentURLSuccessTimeout = setTimeout( function() { successElement.addClass( 'hidden' ); + // No need to store the previous success element further. + previousSuccessElement = null; }, 3000 ); + previousSuccessElement = successElement; + // Handle success audible feedback. wp.a11y.speak( wp.i18n.__( 'The file URL has been copied to your clipboard' ) ); } ); |