There was an issue with a Bootstrap 5 project where the offcanvas menu would remain open after clicking on an anchor link.
Is there a way to automatically close the offcanvas menu after clicking on an anchor link?
<nav class="navbar fixed-top py-5 ">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<img src="photo.jpeg" alt="Image"
class=" image img-fluid rounded-circle position-absolute top-100 start-50 translate-middle ">
</a>
<div style="position: fixed; width: 100%; z-index: 1;">
<button class="navbar-toggler" type="button" data-bs-toggle="offcanvas"
data-bs-target="#offcanvasNavbar" aria-controls="offcanvasNavbar">
<span class="navbar-toggler-icon"></span>
</button>
</div>
<div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasNavbar"
aria-labelledby="offcanvasNavbarLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="offcanvasNavbarLabel">Index</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas"
aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<ul class="navbar-nav justify-content-end flex-grow-1 pe-3">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#Home" >Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#service-section">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#work-section">Works</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact-section">Contact</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#moreinfo-section">More Info</a>
</li>
</ul>
</div>
</div>
</div>
</nav>