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

fix(nhsuk-frontend-react): clean up mobile menu and fix variant #148

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/quick-zebras-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nhsuk-frontend-react": patch
---

fix(nhsuk-frontend-react): clean up mobile menu and fix variant
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,15 @@ const HeaderNavList = factory<HeaderNavListFactory>(
return;
}

// this is a hack to remove the existing mobile menu list
const list = internalRef.current.querySelector(
'li.nhsuk-mobile-menu-container > ul.nhsuk-header__drop-down',
);

if (list) {
list.remove();
}

initHeader();
}, [internalRef, children]);

Expand Down Expand Up @@ -356,14 +365,14 @@ const HeaderNavItem = polymorphicFactory<HeaderNavItemFactory>(
ref,
) => {
return (
<li className="nhsuk-header__navigation-item">
<li
className={clsx('nhsuk-header__navigation-item', {
'nhsuk-header__navigation-item--home': variant === 'home-link',
})}
>
<Base
as={component}
className={clsx(
'nhsuk-header__navigation-link',
{ 'nhsuk-header__navigation-item--home': variant === 'home-link' },
className,
)}
className={clsx('nhsuk-header__navigation-link', className)}
{...props}
ref={ref}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ exports[`should render the Header component 1`] = `
</a>
</li>
<li
class="nhsuk-header__navigation-item"
class="nhsuk-header__navigation-item nhsuk-header__navigation-item--home"
>
<a
class="nhsuk-header__navigation-link nhsuk-header__navigation-item--home"
class="nhsuk-header__navigation-link"
href="#"
>
Home
Expand Down Expand Up @@ -433,10 +433,10 @@ exports[`should render the Header component with a service name 1`] = `
</a>
</li>
<li
class="nhsuk-header__navigation-item"
class="nhsuk-header__navigation-item nhsuk-header__navigation-item--home"
>
<a
class="nhsuk-header__navigation-link nhsuk-header__navigation-item--home"
class="nhsuk-header__navigation-link"
href="#"
>
Home
Expand Down Expand Up @@ -838,10 +838,10 @@ exports[`should render the Header component with an organisation 1`] = `
</a>
</li>
<li
class="nhsuk-header__navigation-item"
class="nhsuk-header__navigation-item nhsuk-header__navigation-item--home"
>
<a
class="nhsuk-header__navigation-link nhsuk-header__navigation-item--home"
class="nhsuk-header__navigation-link"
href="#"
>
Home
Expand Down