Merge pull request #1125 from ae-utbm/navbar-keyboard-navigation

Disable mouse click on navbar for desktop
This commit is contained in:
Bartuccio Antoine 2025-06-16 12:25:33 +02:00 committed by GitHub
commit 1c14bb22a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -108,20 +108,30 @@
{% block script %}
<script>
const menuItems = document.querySelectorAll(".navbar details[name='navbar'].menu");
const isMobile = () => {
const isDesktop = () => {
return window.innerWidth >= 500;
}
for (const item of menuItems){
item.addEventListener("mouseover", () => {
if (isMobile()){
if (isDesktop()){
item.setAttribute("open", "");
}
})
item.addEventListener("mouseout", () => {
if (isMobile()){
if (isDesktop()){
item.removeAttribute("open");
}
})
item.addEventListener("click", (event) => {
// Ignore keyboard clicks
if (event.detail === 0){
return;
}
if (isDesktop()){
event.preventDefault();
}
})
}
function showMenu() {