Skip to content

Commit 83bcc3c

Browse files
authored
docs(cheatsheet): fix JS errors in setActiveItem() (#34011)
1 parent 58b1be9 commit 83bcc3c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

site/content/docs/5.0/examples/cheatsheet/cheatsheet.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
toast.show()
2626
})
2727

28-
// Disable empty links
29-
document.querySelectorAll('[href="#"]')
28+
// Disable empty links and submit buttons
29+
document.querySelectorAll('[href="#"], [type="submit"]')
3030
.forEach(function (link) {
3131
link.addEventListener('click', function (event) {
3232
event.preventDefault()
@@ -41,6 +41,11 @@
4141
}
4242

4343
var link = document.querySelector('.bd-aside a[href="' + hash + '"]')
44+
45+
if (!link) {
46+
return
47+
}
48+
4449
var active = document.querySelector('.bd-aside .active')
4550
var parent = link.parentNode.parentNode.previousElementSibling
4651

0 commit comments

Comments
 (0)