Skip to content

Commit 8279945

Browse files
authored
Fix dropdown on safari (#1087)
* Fix dropdown on safari * Make sure dropdown is closed in safari * Remove tabindex where not needed
1 parent 8f21a3c commit 8279945

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/Elastic.Markdown/Assets/pages-nav.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@ export function initNav() {
5050

5151
const pagesDropdown = $('#pages-dropdown')
5252
if (pagesDropdown) {
53-
const activeAnchor = $('a.pages-dropdown_active', pagesDropdown)
54-
activeAnchor?.addEventListener('mousedown', (e) => {
55-
e.preventDefault()
53+
const anchors = $$('a', pagesDropdown)
54+
anchors.forEach((a) => {
55+
a.addEventListener('mousedown', (e) => {
56+
e.preventDefault()
57+
})
58+
a.addEventListener('mouseup', () => {
59+
if (document.activeElement instanceof HTMLElement) {
60+
document.activeElement.blur()
61+
}
62+
})
5663
})
5764
}
5865

59-
const allNavItems = $$('a', pagesNav)
60-
allNavItems.forEach((link) => {
61-
link.addEventListener('click', () => {
62-
link.closest('details').removeAttribute('open')
63-
})
64-
})
65-
6666
const navItems = $$(
6767
'a[href="' +
6868
window.location.pathname +

src/Elastic.Markdown/Slices/Layout/_TocTree.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@if (Model.IsPrimaryNavEnabled && current is { Group.Index: not null })
88
{
99
<div class="sticky top-0 py-6 bg-white z-10 border-b-1 border-grey-20 pr-4">
10-
<div id="pages-dropdown" class="block group border-1 border-grey-20 rounded-sm font-sans relative">
10+
<div tabindex="0" id="pages-dropdown" class="block group border-1 border-grey-20 rounded-sm font-sans relative">
1111
<button class="w-full text-left grid grid-cols-[1fr_auto] cursor-pointer font-semibold gap-1 hover:text-black pl-4 pr-2 py-2 group-open:border-b-1 border-grey-20">
1212
<div>
1313
<a

0 commit comments

Comments
 (0)