[wp-trac] [WordPress Trac] #49540: Regression: Copy action now scrolls up the page on the privacy policy guide.

WordPress Trac noreply at wordpress.org
Mon Mar 2 06:51:38 UTC 2020


#49540: Regression: Copy action now scrolls up the page on the privacy policy
guide.
-------------------------------------------------+-------------------------
 Reporter:  garrett-eclipse                      |       Owner:  garrett-
                                                 |  eclipse
     Type:  defect (bug)                         |      Status:  accepted
 Priority:  normal                               |   Milestone:  5.4
Component:  Privacy                              |     Version:  trunk
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-screenshots needs-     |     Focuses:  ui
  testing                                        |
-------------------------------------------------+-------------------------
Changes (by garrett-eclipse):

 * keywords:  has-patch has-screenshots => has-patch has-screenshots needs-
     testing


Comment:

 After some more testing I found the use of `scrollIntoView` with either
 the true/false option set for indicating top/bottom alignment causes the
 screen to jump in certain scenarios and as such isn't overly desirable.

 With that in mind I switched implementations in
 [https://core.trac.wordpress.org/attachment/ticket/49540/49540.4.diff
 49540.4.diff] to store the current scrollTop and then reset it after the
 copy action. This will ensure the users is brought back exactly where they
 were before leaving no jump and the only visual cue that anything occurred
 is the appearance of the scroll bar.

 Testing cross-browser I found not all browsers supported
 `document.documentElement.scrollTop`, but those did support
 `document.body.scrollTop` so I opted for a compatible workaround to
 support all browsers.
 Firefox - Never had the issue so no scroll action occurs.
 Safari/Opera - Only supported `document.body.scrollTop`.
 Chrome/Brave - Only supported `document.documentElement.scrollTop`
 IE - I haven't been able to test.

 I feel this is the best approach and am happy to move forward with this if
 a confirmation on IE can be done.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49540#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list