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:
parent
7dd3e6edd9
commit
60f78cd845
|
@ -274,6 +274,9 @@ jQuery( document ).ready( function( $ ) {
|
||||||
|
|
||||||
if ( $container.length ) {
|
if ( $container.length ) {
|
||||||
try {
|
try {
|
||||||
|
var documentPosition = document.documentElement.scrollTop,
|
||||||
|
bodyPosition = document.body.scrollTop;
|
||||||
|
|
||||||
window.getSelection().removeAllRanges();
|
window.getSelection().removeAllRanges();
|
||||||
range = document.createRange();
|
range = document.createRange();
|
||||||
$container.addClass( 'hide-privacy-policy-tutorial' );
|
$container.addClass( 'hide-privacy-policy-tutorial' );
|
||||||
|
@ -284,6 +287,12 @@ jQuery( document ).ready( function( $ ) {
|
||||||
|
|
||||||
$container.removeClass( 'hide-privacy-policy-tutorial' );
|
$container.removeClass( 'hide-privacy-policy-tutorial' );
|
||||||
window.getSelection().removeAllRanges();
|
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 ) {}
|
} catch ( er ) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue