From 0538f64d01deff9d685cf7bf5960c8010a623a44 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 17 Sep 2024 14:39:39 -0700 Subject: [PATCH 1/6] apply 62019 patch from dhruvang21 --- src/js/_enqueues/admin/user-profile.js | 25 ++++++++++++++++++++++++- src/wp-admin/css/common.css | 5 +++++ src/wp-admin/user-edit.php | 2 ++ src/wp-includes/script-loader.php | 2 +- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/js/_enqueues/admin/user-profile.js b/src/js/_enqueues/admin/user-profile.js index 54215c7b420b8..99e5a0c0e4fa9 100644 --- a/src/js/_enqueues/admin/user-profile.js +++ b/src/js/_enqueues/admin/user-profile.js @@ -7,6 +7,7 @@ var updateLock = false, isSubmitting = false, __ = wp.i18n.__, + clipboard = new ClipboardJS( '.application-password-display .copy-button' ), $pass1Row, $pass1, $pass2, @@ -18,7 +19,8 @@ currentPass, $form, originalFormContent, - $passwordWrapper; + $passwordWrapper, + successTimeout; function generatePassword() { if ( typeof zxcvbn !== 'function' ) { @@ -346,6 +348,27 @@ } } + // Debug information copy section. + clipboard.on( 'success', function( e ) { + var triggerElement = $( e.trigger ), + successElement = $( '.success', triggerElement.closest( '.application-password-display' ) ); + + // Clear the selection and move focus back to the trigger. + e.clearSelection(); + + // Show success visual feedback. + clearTimeout( successTimeout ); + successElement.removeClass( 'hidden' ); + + // Hide success visual feedback after 3 seconds since last success. + successTimeout = setTimeout( function() { + successElement.addClass( 'hidden' ); + }, 3000 ); + + // Handle success audible feedback. + wp.a11y.speak( __( 'Site information has been copied to your clipboard.' ) ); + } ); + $( function() { var $colorpicker, $stylesheet, user_id, current_user_id, select = $( '#display_name' ), diff --git a/src/wp-admin/css/common.css b/src/wp-admin/css/common.css index 287f2ee7b4958..8d5486e797606 100644 --- a/src/wp-admin/css/common.css +++ b/src/wp-admin/css/common.css @@ -916,6 +916,11 @@ a#remove-post-thumbnail:hover, border: none; } +.application-password-display .success { + color: #007017; + margin-left: 0.5rem; +} + /*------------------------------------------------------------------------------ 3.0 - Actions ------------------------------------------------------------------------------*/ diff --git a/src/wp-admin/user-edit.php b/src/wp-admin/user-edit.php index 860a0a6e07340..92f32ad19803f 100644 --- a/src/wp-admin/user-edit.php +++ b/src/wp-admin/user-edit.php @@ -984,6 +984,8 @@ ?> + +

+

From 85196fb7ad711820d525e30e255005bba74d823c Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 17 Sep 2024 14:49:13 -0700 Subject: [PATCH 3/6] add ClipboardJS to list of global vars for linting --- src/js/_enqueues/admin/user-profile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/_enqueues/admin/user-profile.js b/src/js/_enqueues/admin/user-profile.js index 99e5a0c0e4fa9..b2cca450b3ba4 100644 --- a/src/js/_enqueues/admin/user-profile.js +++ b/src/js/_enqueues/admin/user-profile.js @@ -2,7 +2,7 @@ * @output wp-admin/js/user-profile.js */ -/* global ajaxurl, pwsL10n, userProfileL10n */ +/* global ajaxurl, pwsL10n, userProfileL10n, ClipboardJS */ (function($) { var updateLock = false, isSubmitting = false, From fd39081bf8d66bad71a611e73873e591a8203ea8 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 17 Sep 2024 15:08:48 -0700 Subject: [PATCH 4/6] update application password e2e test to reflect changes --- tests/e2e/specs/profile/applications-passwords.test.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/e2e/specs/profile/applications-passwords.test.js b/tests/e2e/specs/profile/applications-passwords.test.js index 38aed7372eace..bb7db439d3bba 100644 --- a/tests/e2e/specs/profile/applications-passwords.test.js +++ b/tests/e2e/specs/profile/applications-passwords.test.js @@ -31,7 +31,12 @@ test.describe( 'Manage applications passwords', () => { await expect( successMessage ).toContainText( - `Your new password for ${TEST_APPLICATION_NAME} is: \n\nBe sure to save this in a safe location. You will not be able to retrieve it.` + `Your new password for ${TEST_APPLICATION_NAME} is:` + ); + await expect( + successMessage + ).toContainText( + `Be sure to save this in a safe location. You will not be able to retrieve it.` ); } ); From 18b6243532f3cc27650993a4ec74230c3fa21139 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 17 Sep 2024 18:36:14 -0400 Subject: [PATCH 5/6] Update src/js/_enqueues/admin/user-profile.js Co-authored-by: Jeremy Felt --- src/js/_enqueues/admin/user-profile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/_enqueues/admin/user-profile.js b/src/js/_enqueues/admin/user-profile.js index b2cca450b3ba4..2aebe62a91f94 100644 --- a/src/js/_enqueues/admin/user-profile.js +++ b/src/js/_enqueues/admin/user-profile.js @@ -366,7 +366,7 @@ }, 3000 ); // Handle success audible feedback. - wp.a11y.speak( __( 'Site information has been copied to your clipboard.' ) ); + wp.a11y.speak( __( 'Application password has been copied to your clipboard.' ) ); } ); $( function() { From 623dce811d93be57136031292d37848eebfc82ba Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 17 Sep 2024 16:32:41 -0700 Subject: [PATCH 6/6] adjust spacing between input and copy button (this only applies in some small screen sizes when this wraps into multiple lines) --- src/wp-admin/css/forms.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wp-admin/css/forms.css b/src/wp-admin/css/forms.css index 41d592d148811..ffe2c1711e7a1 100644 --- a/src/wp-admin/css/forms.css +++ b/src/wp-admin/css/forms.css @@ -1002,6 +1002,7 @@ table.form-table td .updated p { } .application-password-display input.code { + margin-bottom: 6px; width: 19em; }