Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report: flexible viewport for element screenshot overlay #11843

Closed
wants to merge 3 commits into from

Conversation

connorjclark
Copy link
Collaborator

@connorjclark connorjclark commented Dec 16, 2020

This resolves a bug where the overlay was not properly sized in CDT. Instead of using the document window is devtools to know how to center the overlay, for CDT we should use the container element size. Also moved the overlay element to be right after the topbar, and had to make it sticky.

To test you need to patch this CL to a checkout of devtools frontend, and run:

DEVTOOLS_PATH=/Users/cjamcl/src/devtools/devtools-frontend yarn open-devtools

@connorjclark connorjclark requested a review from a team as a code owner December 16, 2020 22:25
@connorjclark connorjclark requested review from patrickhulce and removed request for a team December 16, 2020 22:25
@google-cla google-cla bot added the cla: yes label Dec 16, 2020
Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bummer that our devtools tests can't cover any of this stuff :(

if (reportEl.classList.contains(screenshotOverlayClass)) return;
reportEl.classList.add(screenshotOverlayClass);
const topbarEl = dom.find('.lh-topbar', dom.document());
const containerEl = topbarEl.parentElement;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah so this should be the .lh-report in the standalone report, but might be different in DevTools/PSI?

Copy link
Collaborator Author

@connorjclark connorjclark Dec 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope. lh-report is inside lh-container.

standalone report:

image

CDT:

image
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for whatever reason we have a <main> in standalone. and that elem isn't there for devtools. (not sure about PSI, but probably one of those)

we could be normalizing this DOM structure a bit more but.. yah it's currently not.

height: dom.document().documentElement.clientHeight * 0.75,
};
if (dom.isDevTools()) {
maxLightboxSize.width = containerEl.clientWidth;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason we don't always do the Math.min of these? is the below correct?

In devtools:

  • the container is the inner area available to our pane
  • the document is the entire devtools area

In standalone:

  • the container is the very tall lh-report element
  • the document is the window

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the below correct?

yes

is there a reason we don't always do the Math.min of these?

That would work. I find this easier to reason about though. Although using the min would possible benefit other embedders..is that your goal here?

overlay.remove();
});

reportEl.appendChild(overlay);
containerEl.insertBefore(overlay, topbarEl.nextElementSibling);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there seems to be significance to the fact that the overlap comes immediately after the topbar. if so, comment? if not, stick with appendChild on the container?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

if not, stick with appendChild on the container?

It doesn't render if placed after lh-container.

height: 100vh;
z-index: 1;
z-index: 1001;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
z-index: 1001;
z-index: 2000; /* .lh-topbar is 1000 */

@@ -1549,12 +1549,11 @@
outline: 2px solid var(--color-lime-400);
}
.lh-element-screenshot__overlay {
position: fixed;
position: sticky;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does fix some weird layout business in devtools but it shifts the content down so its not longer behind the overlay

before / after

overlay

i think there's an alternate approach that handles this and also sorts out the bugs.

i'm noodling on it over here………

if (reportEl.classList.contains(screenshotOverlayClass)) return;
reportEl.classList.add(screenshotOverlayClass);
const topbarEl = dom.find('.lh-topbar', dom.document());
const containerEl = topbarEl.parentElement;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for whatever reason we have a <main> in standalone. and that elem isn't there for devtools. (not sure about PSI, but probably one of those)

we could be normalizing this DOM structure a bit more but.. yah it's currently not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants