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-136885: More SEO-friendly, improved accessibility in merch cards #1791

Merged
merged 15 commits into from
Feb 22, 2024

Conversation

Axelcureno
Copy link
Member

@Axelcureno Axelcureno commented Jan 26, 2024

Programmatically replaces heading tag names in cascading order to improve SEO and accessibility in Merch cards.
The hierarchal order is the following:

  • 1st heading: H3
  • 2nd heading: H4
  • 3rd heading: H5

Note: No merch card should have more than 3 headings.

Resolves: MWPW-136885

Test URLs:

@Axelcureno Axelcureno added run-nala Run Nala Test Automation against PR commerce merch card labels Jan 26, 2024
@Axelcureno Axelcureno self-assigned this Jan 26, 2024
Copy link

codecov bot commented Jan 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.66%. Comparing base (6701caa) to head (7167df2).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1791      +/-   ##
==========================================
- Coverage   95.67%   95.66%   -0.01%     
==========================================
  Files         159      159              
  Lines       41254    41262       +8     
==========================================
+ Hits        39471    39475       +4     
- Misses       1783     1787       +4     

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

libs/blocks/merch-card/merch-card.js Outdated Show resolved Hide resolved
}
element.setAttribute('slot', slotName);
merchCard.append(element);
const newElement = createTag(tagName);
Copy link
Contributor

Choose a reason for hiding this comment

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

const newElement = createTag(tagName, element.attributes, element.innerHTML, { parent: merchCard});

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

does not look like it

Copy link
Member Author

@Axelcureno Axelcureno Jan 26, 2024

Choose a reason for hiding this comment

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

Sorry, I got confused with the another comment.
I tried doing your suggestion, but it seems element.attributes returns a NamedNodeMap which is not compatible with createTag().
Screenshot 2024-01-26 at 2 36 25 PM

libs/blocks/merch-card/merch-card.js Outdated Show resolved Hide resolved
@Axelcureno Axelcureno added the needs-verification PR requires E2E testing by a reviewer label Jan 26, 2024
Copy link
Contributor

aem-code-sync bot commented Jan 26, 2024

Page Scores Audits Google
/docs/library/kitchen-sink/merch-card PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@rgclayton
Copy link
Contributor

A few observations.

If I author the title with an <h> tag other than <h3> the font size is different. The DOM is changed to an <h3> though if it's the first title, like your code says.

To me it seems like if you are going to the trouble to change the title element to something specific the font size should stay consistent? Or maybe that's expected? Seems odd.

If I author with an <h1>, <h5> or <h6> the title is not rendered at all. Why not look for these so they at least render?

Sample page I test with.

image

@Roycethan Roycethan added verified PR has been E2E tested by a reviewer and removed needs-verification PR requires E2E testing by a reviewer labels Jan 26, 2024
@Axelcureno
Copy link
Member Author

A few observations.

If I author the title with an <h> tag other than <h3> the font size is different. The DOM is changed to an <h3> though if it's the first title, like your code says.

To me it seems like if you are going to the trouble to change the title element to something specific the font size should stay consistent? Or maybe that's expected? Seems odd.

If I author with an <h1>, <h5> or <h6> the title is not rendered at all. Why not look for these so they at least render?

Sample page I test with.

image

@rgclayton thanks for the comment, you brought a good point.
I started a discussion about it to make things easier for authors: https://github.com/orgs/adobecom/discussions/1799

Copy link
Contributor

@npeltier npeltier left a comment

Choose a reason for hiding this comment

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

requesting discussion to be solved before going on :)

@Axelcureno Axelcureno added the do not merge PR should not be merged yet label Jan 29, 2024
@Axelcureno Axelcureno requested a review from npeltier January 30, 2024 19:14
@Axelcureno Axelcureno requested a review from a team as a code owner February 7, 2024 21:04
@Roycethan Roycethan added needs-verification PR requires E2E testing by a reviewer and removed verified PR has been E2E tested by a reviewer labels Feb 21, 2024
@Axelcureno Axelcureno merged commit 210cd05 into adobecom:main Feb 22, 2024
10 of 11 checks passed
@Axelcureno Axelcureno removed do not merge PR should not be merged yet needs-verification PR requires E2E testing by a reviewer labels Feb 22, 2024
yesil pushed a commit to yesil/milo that referenced this pull request Mar 4, 2024
…adobecom#1791)

* MWPW-136885: More SEO-friendly, improved accessibility merch cards

* unit tests fixed

* addressed review comments

* updated merch card dependency

* conflicts resolved
yesil pushed a commit to yesil/milo that referenced this pull request Mar 4, 2024
…adobecom#1791)

* MWPW-136885: More SEO-friendly, improved accessibility merch cards

* unit tests fixed

* addressed review comments

* updated merch card dependency

* conflicts resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commerce merch card run-nala Run Nala Test Automation against PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants