Skip to content

UDS-1998: feat(components-core): added close functionality when clicking an anchor in the Anchor menu #1529

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

Closed
wants to merge 3 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ export const AnchorMenu = ({
queryFirstFocusable(`#${container}`)?.focus();

window.scrollTo({ top: scrollTo, behavior: "smooth" });
setState(prevState => ({
...prevState,
showMenu: false,
}));
};

const handleMenuVisibility = () => {
Expand Down Expand Up @@ -207,7 +211,7 @@ export const AnchorMenu = ({
style={state.showMenu ? { borderBottom: 0 } : {}}
>
<div className={`${state.containerClass} uds-anchor-menu-wrapper`}>
{isSmallDevice ? (
{(isSmallDevice || isBootstrap) ? (
<GaEventWrapper
gaData={{
...defaultMobileGAEvent,
Expand All @@ -219,9 +223,9 @@ export const AnchorMenu = ({
[`show-menu`]: state.showMenu,
})}
type="button"
onClick={handleMenuVisibility}
data-bs-toggle="collapse"
data-bs-target="#collapseAnchorMenu"
onClick={isReact && handleMenuVisibility}
data-bs-toggle={isBootstrap && "collapse"}
data-bs-target={isBootstrap && "#collapseAnchorMenu"}
aria-controls="collapseAnchorMenu"
>
<h4>
Expand Down Expand Up @@ -261,6 +265,8 @@ export const AnchorMenu = ({
isReact && (() => handleClickLink(item.targetIdName))
}
href={isBootstrap && `#${item.targetIdName}`}
data-bs-toggle={isBootstrap && "collapse"}
data-bs-target={isBootstrap && "#collapseAnchorMenu"}
/>
))}
</nav>
Expand Down