Wait, are you saying that those items should be links and also expand the submenu? How is that supposed to work? As soon as you click a link you navigate away from the page, so any submenu that expands is pointless as the user won’t see it.
The problem with that approach in general is that it won’t work any more as soon as you have any other anchor links on the same page… it’s certainly nice what you can achieve with CSS alone, but IME those tricks rarely work well on a real page.
For a more robust JS solution you might remember the active submenu toggle, and toggle() the show class depending on whether or not the currently clicked toggle is the active one:
var toggles = document.querySelectorAll('.submenu-toggle')
var active = null
function toggleSubmenus (event) {
var current = event.target
var isCurrentActive = current === active
toggles.forEach(function (toggle) {
// Only add the "show" class if the toggle is the one that has been
// clicked, and if that toggle hasn't been active before; otherwise,
// remove the class
toggle.classList.toggle('show', toggle === current && !isCurrentActive)
})
// Remember the currently active toggle,
// or unset it if it was active before
active = isCurrentActive ? null : current
}
toggles.forEach(function(toggle) {
toggle.addEventListener('click', toggleSubmenus)
})