From 18e3aa433c872662f888e26550d382f989ae8f0a Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 3 Mar 2020 17:51:05 +0000 Subject: [PATCH] Privacy: Prevent unexpected scrolling when clicking the "Copy this section to clipboard" button on Privacy Policy Guide screen. Props garrett-eclipse, birgire, davidbaumwald, pbiron. Fixes #49540. Built from https://develop.svn.wordpress.org/trunk@47420 git-svn-id: http://core.svn.wordpress.org/trunk@47207 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/privacy-tools.js | 9 +++++++++ wp-admin/js/privacy-tools.min.js | 2 +- wp-includes/version.php | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/wp-admin/js/privacy-tools.js b/wp-admin/js/privacy-tools.js index b8b88ac7da..d00d5d1573 100644 --- a/wp-admin/js/privacy-tools.js +++ b/wp-admin/js/privacy-tools.js @@ -274,6 +274,9 @@ jQuery( document ).ready( function( $ ) { if ( $container.length ) { try { + var documentPosition = document.documentElement.scrollTop, + bodyPosition = document.body.scrollTop; + window.getSelection().removeAllRanges(); range = document.createRange(); $container.addClass( 'hide-privacy-policy-tutorial' ); @@ -284,6 +287,12 @@ jQuery( document ).ready( function( $ ) { $container.removeClass( 'hide-privacy-policy-tutorial' ); window.getSelection().removeAllRanges(); + + if ( documentPosition > 0 && documentPosition !== document.documentElement.scrollTop ) { + document.documentElement.scrollTop = documentPosition; + } else if ( bodyPosition > 0 && bodyPosition !== document.body.scrollTop ) { + document.body.scrollTop = bodyPosition; + } } catch ( er ) {} } } diff --git a/wp-admin/js/privacy-tools.min.js b/wp-admin/js/privacy-tools.min.js index 418f89678f..28c6d2faa5 100644 --- a/wp-admin/js/privacy-tools.min.js +++ b/wp-admin/js/privacy-tools.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -jQuery(document).ready(function(g){var h=window.privacyToolsL10n||{};function w(e,t){e.children().addClass("hidden"),e.children("."+t).removeClass("hidden")}function x(e){e.removeClass("has-request-results"),e.next().hasClass("request-results")&&e.next().remove()}function C(e,t,n,a){var o="",s="request-results";x(e),a.length&&(g.each(a,function(e,t){o=o+"
  • "+t+"
  • "}),o=""),e.addClass("has-request-results"),e.hasClass("status-request-confirmed")&&(s+=" status-request-confirmed"),e.hasClass("status-request-failed")&&(s+=" status-request-failed"),e.after(function(){return'

    '+n+"

    "+o+"
    "})}g(".export-personal-data-handle").click(function(e){var t=g(this),s=t.parents(".export-personal-data"),r=t.parents("tr"),a=r.find(".export-progress"),i=t.parents(".row-actions"),c=s.data("request-id"),d=s.data("nonce"),u=s.data("exporters-count"),l=!!s.data("send-as-email");function p(e){w(s,"export-personal-data-failed"),e&&C(r,"notice-error",h.exportError,[e]),setTimeout(function(){i.removeClass("processing")},500)}function m(e){var t=0"+t+""}),a=""),e.addClass("has-request-results"),e.hasClass("status-request-confirmed")&&(s+=" status-request-confirmed"),e.hasClass("status-request-failed")&&(s+=" status-request-failed"),e.after(function(){return'

    '+o+"

    "+a+"
    "})}g(".export-personal-data-handle").click(function(e){var t=g(this),s=t.parents(".export-personal-data"),r=t.parents("tr"),n=r.find(".export-progress"),i=t.parents(".row-actions"),c=s.data("request-id"),d=s.data("nonce"),u=s.data("exporters-count"),l=!!s.data("send-as-email");function p(e){w(s,"export-personal-data-failed"),e&&T(r,"notice-error",h.exportError,[e]),setTimeout(function(){i.removeClass("processing")},500)}function m(e){var t=0