|
224 | 224 | event.stopPropagation(); |
225 | 225 |
|
226 | 226 | // hide any other active dropdowns |
227 | | - const allActiveDropdowns = document.querySelectorAll(".nav-link.current"); |
| 227 | + // Added [data-toggle='dropdown'] so it ignores active page links like #cloud or #kanvas |
| 228 | + const allActiveDropdowns = document.querySelectorAll(".nav-link.current[data-toggle='dropdown']"); |
228 | 229 | allActiveDropdowns.forEach((otherDropdown) => { |
229 | 230 | if (otherDropdown !== dropdown) { |
230 | 231 | otherDropdown.classList.remove("current"); |
231 | | - otherDropdown.nextElementSibling.classList.remove("show"); |
232 | | - otherDropdown.nextElementSibling.style.visibility = "hidden"; |
233 | | - } |
234 | | - }); |
235 | | - |
236 | | - if (dropdown.classList.contains("current")) { |
237 | | - dropdown.classList.remove("current"); |
238 | | - dropdownMenu.classList.remove("show"); |
239 | | - dropdownMenu.style.visibility = "hidden"; |
240 | | - } else { |
241 | | - dropdown.classList.toggle("current"); |
242 | | - dropdownMenu.classList.toggle("show"); |
243 | | - dropdownMenu.style.visibility = "visible"; |
244 | | - } |
245 | | - }); |
246 | | - |
247 | | - document.body.addEventListener('click', function() { |
248 | | - if (dropdown.classList.contains("current")) { |
249 | | - dropdown.classList.remove("current"); |
250 | | - dropdownMenu.classList.remove("show"); |
251 | | - dropdownMenu.style.visibility = "hidden"; |
252 | | - } |
| 232 | + const menu = otherDropdown.nextElementSibling; |
| 233 | + if (menu) { |
| 234 | + menu.classList.remove("show"); |
| 235 | + menu.style.visibility = "hidden"; |
| 236 | + } |
| 237 | + } |
| 238 | + }); |
| 239 | + |
| 240 | + if (dropdown.classList.contains("current")) { |
| 241 | + dropdown.classList.remove("current"); |
| 242 | + dropdownMenu.classList.remove("show"); |
| 243 | + dropdownMenu.style.visibility = "hidden"; |
| 244 | + } |
| 245 | + else { |
| 246 | + dropdown.classList.toggle("current"); |
| 247 | + dropdownMenu.classList.toggle("show"); |
| 248 | + dropdownMenu.style.visibility = "visible"; |
| 249 | + } |
| 250 | + }); |
| 251 | + |
| 252 | + document.body.addEventListener('click', function() { |
| 253 | + if (dropdown.classList.contains("current")) { |
| 254 | + dropdown.classList.remove("current"); |
| 255 | + dropdownMenu.classList.remove("show"); |
| 256 | + dropdownMenu.style.visibility = "hidden"; |
| 257 | + } |
253 | 258 | }); |
254 | 259 | } |
255 | 260 |
|
|
0 commit comments