New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 667198 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Not on Chrome
Closed: Jan 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug-Regression

Blocking:
issue 671375



Sign in to add a comment

getBoundingClientRect returns wrong values after resizing page.

Reported by jshan...@etouch.net, Nov 21 2016

Issue description

Chrome Version: 57.0.2926.0 (Official Build) da59d418f54604ba2451cd0ef3a9cd42c05ca530-refs/heads/master@{#433437}-32/64 bit
OS:Windows(7,8,8.1,10),Linux (14.04 LTS),Mac OS X(10.11.6, 10.12.1)

What steps will reproduce the problem?
(1)Launch chrome and navigate to chrome://md-settings/
(2)Click on "open a specific page.." radio button , click on 'use current pages' button.
(3)Click on iron icon and click anywhere on page such that list closes.
(4)Now click on'restore down' button, resize window from R.H.S and again click on same iron icon observe.

Actual: Focus issue observed after clicking on iron icon if browser window is resized.

Expected: Focus should not disappear after clicking on iron icon (i.e after step 4)

This is a regression issue broken in 'M56' and below is the manual regression range:
Good Build: 56.0.2900.0 
Bad Build:  56.0.2901.4

 
Actual.mp4
515 KB View Download

Comment 1 by jshan...@etouch.net, Nov 21 2016

Labels: hasbisect OS-Linux
Owner: dpa...@chromium.org
Status: Assigned (was: Unconfirmed)
Narrow bisect:
https://chromium.googlesource.com/chromium/src/+log/d5bbc0a84e55a4e4fe98394cfd265eb7e51ff63a..8a1482f49a54148bdb239261e7582555c8984663?pretty=fuller&n=30

Suspecting: 427248 ?
Kindly help to re-assign, if your changes are not cause for this issue.

Comment 2 by dpa...@chromium.org, Nov 21 2016

Cc: dbeam@chromium.org
Components: Blink>Layout
Owner: ----
Status: Available (was: Assigned)
Summary: getBoundingClientRect returns wrong values after resizing page. (was: Regression:Focus issue observed after clicking on iron icon if browser window is resized.)
The problem is not the focus. The problem is that the menu opens at a random place the 2nd time you click, instead of opening close to the anchor element. Attaching a screencast showing the problem.

Repro (see video)
1) Open and close action menu once, see correct bounding client rect values being printed.
2) Decrease the width of the window.
3) Open action menu again, Menu is shown at a random location, and getBoundingClientRect values are wrong (especially the 'left' value).
4) Close and re-open, menu shows up at the correct location.

FYI, this is the 2nd getBoundingClientRect bug that affects cr-action-menu, perhaps they are related (https://bugs.chromium.org/p/chromium/issues/detail?id=662300).
getboundingclient_bug.mp4
1.5 MB View Download

Comment 3 by dpa...@chromium.org, Nov 21 2016

Labels: Proj-MaterialDesign-WebUI

Comment 4 by dbeam@chromium.org, Nov 22 2016

Cc: esprehn@chromium.org
a puppy dies every time getBoundingClientRect() returned a mistakenly cached value
Just for update,Still able to reproduce the issue on Mac 10.11.6 using latest chrome version 57.0.2935.0.

Could anyone please look into this issue.

Thanks!
Cc: ranjitkan@chromium.org dpa...@chromium.org tsergeant@chromium.org hdodda@chromium.org
 Issue 678176  has been merged into this issue.
FWIW, this is now reproducible in the History page without any runtime flags enabled.
Owner: e...@chromium.org
Status: Assigned (was: Available)
We'd need some kind of reduction to diagnose if getBoundingClient rect was returning the wrong values. Sending to eae@ for layout team triage.

Comment 9 by e...@chromium.org, Jan 6 2017

Labels: Needs-Feedback Needs-Reduction
There are no blink changes in the regression range and I have not been able to reproduce this on any platform (win, mac, linux, chromeos).

If you think this is a problem with getBoundingClientRect a reduction would be incredibly helpful.

Components: -Blink>Layout
Owner: tsergeant@chromium.org
Status: Started (was: Assigned)
Stepping through with Devtools reveals the problem is in cr-action-menu:

When showModal() is called, the dialog immediately reappears at the position it was in previously.

If the window has been resized horizontally, the dialog can appear offscreen to the right, messing up the position calculations. 

Resetting the left/top values before reshowing the dialog fixes the issue.
@tsergeant: Per my own debugging at comment#2 (see video), the this.anchorElement_.getBoundingClientRect() call returns wrong values (clearly shown in the video 27s, where left is incorrectly 194.45px, unless I am mistaken).

How is this affected by the previous values of this.style.left/right/top? Even if they where initially messing up the dialog's position, shouldn't the position be corrected by the logic after showModal() (https://cs.chromium.org/chromium/src/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js?l=135-151)?
Blocking: 671375
Labels: Hotlist-MD-Settings-General
#11: Based on what you can see in the video, it does -look- like getBoundingClientRect() returns the wrong values.

However, putting a breakpoint immediately after the call to showModal() shows what's actually happening (screenshots attached, since it's hard to explain in words).

First, the menu reappears using the same top/left values as last time it was shown. This scrolls the window to the right, and so at the point that getBoundingClientRect() is called, the menu button is positioned left of where it would normally appear. Since getBoundingClientRect is relative to the viewport, this position is reflected in the rect that is returned.

cr-action-menu then does the calculations based on that (incorrect) position, and changes its top/left position. This then causes the scroll pane to disappear and the menu button to return to its original position.

Resetting top/left/right prevents that scroll pane from appearing, and so the menu button never moves.
MenuPos1.png
257 KB View Download
MenuPos2.png
243 KB View Download
MenuPos3.png
227 KB View Download
Thanks for the explanation. The sneaky scrolling of the viewport is what I was missing to understand how resetting previous this.style.left/right/top would fix the issue.
Project Member

Comment 15 by bugdroid1@chromium.org, Jan 13 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b1caf20ec92bdf673b7b86adfca7e5121914551a

commit b1caf20ec92bdf673b7b86adfca7e5121914551a
Author: tsergeant <tsergeant@chromium.org>
Date: Fri Jan 13 01:20:20 2017

MD WebUI: Fix incorrect positioning of action menu after window resize

Showing the menu, resizing the browser window horizontally and then
showing the menu a second time could result in incorrectly positioning
the window, as position values from the first instance would affect
layout of the second instance. This fixes the issue by clearing position
alues before reshowing the menu.

BUG= 667198 
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2614663011
Cr-Commit-Position: refs/heads/master@{#443429}

[modify] https://crrev.com/b1caf20ec92bdf673b7b86adfca7e5121914551a/chrome/browser/resources/md_history/lazy_load.crisper.js
[modify] https://crrev.com/b1caf20ec92bdf673b7b86adfca7e5121914551a/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js

Status: Fixed (was: Started)

Sign in to add a comment