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

[MWPW-158773] : Aside notification CLS performance improvements #3536

Open
wants to merge 6 commits into
base: stage
Choose a base branch
from

Conversation

Copy link
Contributor

aem-code-sync bot commented Jan 23, 2025

Copy link

codecov bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.47%. Comparing base (6cb26a3) to head (aadd788).
Report is 48 commits behind head on stage.

Additional details and impacted files
@@           Coverage Diff           @@
##            stage    #3536   +/-   ##
=======================================
  Coverage   96.47%   96.47%           
=======================================
  Files         260      260           
  Lines       60582    60584    +2     
=======================================
+ Hits        58444    58446    +2     
  Misses       2138     2138           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

This pull request is not passing all required checks. Please see this discussion for information on how to get all checks passing. Inconsistent checks can be manually retried. If a test absolutely can not pass for a good reason, please add a comment with an explanation to the PR.

@sharmeeatadobe sharmeeatadobe requested a review from a team January 24, 2025 05:19
@robert-bogos
Copy link
Contributor

robert-bogos commented Jan 27, 2025

For the failing NALA tests you could try to clear the cache with this:
CURL -si -X POST https://admin.hlx.page/code/sharmeeatadobe/milo/mwpw-158773/\*

Copy link
Contributor

@overmyheadandbody overmyheadandbody left a comment

Choose a reason for hiding this comment

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

This might need another look, I see that the image is now in a different position than before. I'm guessing this isn't intentional? The paragraph may have different spacing rules that could differ from / add to the image's ones
Screenshot 2025-01-27 at 15 38 24
Screenshot 2025-01-27 at 15 38 35

@sharmeeatadobe
Copy link
Contributor Author

sharmeeatadobe commented Jan 28, 2025

This might need another look, I see that the image is now in a different position than before. I'm guessing this isn't intentional? The paragraph may have different spacing rules that could differ from / add to the image's ones Screenshot 2025-01-27 at 15 38 24 Screenshot 2025-01-27 at 15 38 35

This is a specific issue due to the image asset itself because the ratio of dimensions of the default image within <picture> tag is not matching the dimensions of the image that gets satisfied.
Whereas I did not find this issue where the ratios are maintained. Tried with few examples here: Eg: https://main--milo--adobecom.hlx.page/drafts/sharmeeb/aside-notification vs https://mwpw-158773--milo--sharmeeatadobe.hlx.page/drafts/sharmeeb/aside-notification

@sharmeeatadobe
Copy link
Contributor Author

For the failing NALA tests you could try to clear the cache with this: CURL -si -X POST https://admin.hlx.page/code/sharmeeatadobe/milo/mwpw-158773/\*

I have tried this a couple of times but cache refresh did not help overcome the failed NALA test. Can we please re-run this since the tests are failing for a an unrelated component wrt this PR

@overmyheadandbody
Copy link
Contributor

@sharmeeatadobe - we can't ask authors to start changing such images, especially since we don't have a way to figure out all the pages where this might occur. Backwards compatibility needs to be maintained, without affecting layout. The tablet view would be even more affected with this change:
Screenshot 2025-01-28 at 14 52 53

We don't want to introduce visual regressions in favor of minor performance enhancements, other solutions should be considered to address this.

CC: @SilviuLCF

@sharmeeatadobe
Copy link
Contributor Author

@sharmeeatadobe - we can't ask authors to start changing such images, especially since we don't have a way to figure out all the pages where this might occur. Backwards compatibility needs to be maintained, without affecting layout. The tablet view would be even more affected with this change: Screenshot 2025-01-28 at 14 52 53

We don't want to introduce visual regressions in favor of minor performance enhancements, other solutions should be considered to address this.

CC: @SilviuLCF

Sure, I'll try with some alternative solution. Do you have any suggestions in mind?

@mokimo mokimo self-requested a review January 30, 2025 09:37
@sharmeeatadobe
Copy link
Contributor Author

@sharmeeatadobe - we can't ask authors to start changing such images, especially since we don't have a way to figure out all the pages where this might occur. Backwards compatibility needs to be maintained, without affecting layout. The tablet view would be even more affected with this change: Screenshot 2025-01-28 at 14 52 53
We don't want to introduce visual regressions in favor of minor performance enhancements, other solutions should be considered to address this.
CC: @SilviuLCF

Sure, I'll try with some alternative solution. Do you have any suggestions in mind?

Have implemented to hide the banner until the image loads. Please review again @overmyheadandbody @mokimo @robert-bogos

@@ -194,6 +194,17 @@ function decorateLayout(el) {
const iconClass = iconVariant ? `${iconVariant[1]}-area` : 'icon-area';
if (iconVariant) loadIconography();
iconArea.classList.add(iconClass);
const image = iconArea.querySelector('img');
if (image) {
Copy link
Contributor

Choose a reason for hiding this comment

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

visible is default value for visibility so there is no need for first nested if

    if (image && !image.complete) {
       el.style.visibility = 'hidden';
       image.addEventListener('load', () => {
       el.style.visibility = 'visible';
      });
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the suggested changes

@zagi25
Copy link
Contributor

zagi25 commented Feb 21, 2025

@sharmeeatadobe along with cache clearing command, merging stage into your branch can help with NALA.

Copy link
Contributor

@JasonHowellSlavin JasonHowellSlavin left a comment

Choose a reason for hiding this comment

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

Is there a test that can be updated to reflect this change in the code?

@sharmeeatadobe
Copy link
Contributor Author

Is there a test that can be updated to reflect this change in the code?

Added test cases in latest commit

export function handleImageLoad(el, image) {
if (image && !image.complete) {
el.style.visibility = 'hidden';
image.addEventListener('load', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

one thing I forgot, shouldn't there be a fallback if for some reason image is not loaded ? Are we okay with aside staying hidden if there is some problem with an image ?
https://developer.mozilla.org/en-US/docs/Web/API/Window/error_event

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

Successfully merging this pull request may close these issues.

6 participants