Skip to content

Commit

Permalink
MWPW-164458: Fix - Breadcrumb has capital I in iPhone (#3499)
Browse files Browse the repository at this point in the history
MWPW-164458: Breadcrumb has capital I in iPhone
  • Loading branch information
nishantka authored Jan 23, 2025
1 parent 13d8ef0 commit 7d4a28d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ const createBreadcrumbs = (element) => {
if (hiddenEntries.includes(li.innerText?.toLowerCase().trim())) li.remove();
});

const noTransform = element.classList.contains('no-transform') ? ' no-transform' : '';

const breadcrumbs = toFragment`
<div class="feds-breadcrumbs-wrapper">
<nav class="feds-breadcrumbs" aria-label="Breadcrumb">${ul}</nav>
<nav class="feds-breadcrumbs${noTransform}" aria-label="Breadcrumb">${ul}</nav>
</div>
`;
ul.querySelector('li:last-of-type')?.setAttribute('aria-current', 'page');
Expand Down
5 changes: 5 additions & 0 deletions libs/blocks/global-navigation/global-navigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,11 @@ header.global-navigation {
text-transform: capitalize;
}

.feds-breadcrumbs.no-transform a,
.feds-breadcrumbs.no-transform [aria-current] {
text-transform: none;
}

.feds-breadcrumbs a {
display: block;
color: var(--feds-color-link-breadcrumbs);
Expand Down
20 changes: 20 additions & 0 deletions test/blocks/global-navigation/features/breadcrumbs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ export const breadcrumbMock = () => toFragment`
</div>
`;

const breadcrumbWithCase = () => toFragment`
<div class="breadcrumbs no-transform">
<div>
<div>
<ul>
<li><a href="http://www.google.com/">Home</a></li>
<li><a href="http://localhost:2000/">Adobe Photoshop</a></li>
<li>Photoshop on iPhone</li>
</ul>
</div>
</div>
</div>
`;

export const assertBreadcrumb = ({ breadcrumb, length }) => {
expect(breadcrumb.querySelector('nav')).to.exist;
expect(breadcrumb.querySelector('ul').children.length).to.equal(length);
Expand Down Expand Up @@ -51,6 +65,12 @@ describe('breadcrumbs', () => {
assertBreadcrumb({ breadcrumb, length: 2 });
});

it('should use make the breadcrumnbs preserve case using css when no-transform modifier is added to block', async () => {
const breadcrumb = await breadcrumbs(breadcrumbWithCase());
assertBreadcrumb({ breadcrumb, length: 3 });
expect(breadcrumb.querySelector('nav').className.includes('no-transform')).to.be.true;
});

it('should use a custom page title and show the current page if set', async () => {
document.head.innerHTML = '<meta name="breadcrumbs-page-title" content="Custom Title"><meta name="breadcrumbs-show-current-page" content="on">';
const breadcrumb = await breadcrumbs(breadcrumbMock());
Expand Down

0 comments on commit 7d4a28d

Please sign in to comment.