Commit a0b6b7cf authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[menus] All submenu in files-ng shall have margin-top: 0

Patch 1 / 3: in the code flow that shows submenu, we must position the
submenu using getComputedStyle. Just before that style recalc, set the
submenu margin-top to 0 using inline style.

The inline style overrides all CSS and all submenu's of files-app have
0 margin-top as a result. In particular, #tasks-menu, #share-menu will
no longer accidently get 8px margin-top (issue 1066727#c23).

Bug: 1066727
Change-Id: I7620d88b5026a436a94b2d1cdefed5acfa3851f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2301610Reviewed-by: default avatarAlex Danilo <adanilo@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789334}
parent 4a4e918f
...@@ -205,14 +205,20 @@ cr.define('cr.ui', () => { ...@@ -205,14 +205,20 @@ cr.define('cr.ui', () => {
* @param {cr.ui.Menu} subMenu The child (sub) menu to be positioned. * @param {cr.ui.Menu} subMenu The child (sub) menu to be positioned.
*/ */
positionSubMenu_(item, subMenu) { positionSubMenu_(item, subMenu) {
const style = subMenu.style;
if (util.isFilesNg()) {
style.marginTop = '0'; // crbug.com/1066727
}
// The sub-menu needs to sit aligned to the top and side of // The sub-menu needs to sit aligned to the top and side of
// the menu-item passed in. It also needs to fit inside the viewport // the menu-item passed in. It also needs to fit inside the viewport
const itemRect = item.getBoundingClientRect(); const itemRect = item.getBoundingClientRect();
const viewportWidth = window.innerWidth; const viewportWidth = window.innerWidth;
const viewportHeight = window.innerHeight; const viewportHeight = window.innerHeight;
const childRect = subMenu.getBoundingClientRect(); const childRect = subMenu.getBoundingClientRect();
const style = subMenu.style;
const maxShift = itemRect.width / 2; const maxShift = itemRect.width / 2;
// See if it fits on the right, if not position on the left // See if it fits on the right, if not position on the left
// if there's more room on the left. // if there's more room on the left.
style.left = style.right = style.top = style.bottom = 'auto'; style.left = style.right = style.top = style.bottom = 'auto';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment