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.

git-svn-id: https://develop.svn.wordpress.org/trunk@47420 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-03-03 17:49:53 +00:00
parent 7dd3e6edd9
commit 60f78cd845
1 changed files with 9 additions and 0 deletions

View File

@ -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 ) {}
}
}