File tree 2 files changed +15
-15
lines changed
2 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -17,15 +17,17 @@ document.addEventListener("click", (e) => {
17
17
} ) ;
18
18
19
19
window . addEventListener ( "load" , ( ) => {
20
- const checkbox = document . getElementById ( "usageDropdownInput" ) ;
20
+ const usageSelector = document . getElementById ( "usageSelector" ) ;
21
+
21
22
document . addEventListener ( "mouseup" , ( e ) => {
22
- const label = findParent (
23
- e . target ,
24
- ( el ) =>
25
- el instanceof HTMLLabelElement && el . htmlFor === "usageDropdownInput" ,
26
- ) ;
27
- if ( ! label ) {
28
- checkbox . checked = false ;
23
+ if (
24
+ findParent (
25
+ e . target ,
26
+ ( el ) =>
27
+ el . parentElement === usageSelector && el instanceof HTMLDivElement ,
28
+ )
29
+ ) {
30
+ usageSelector . open = false ;
29
31
}
30
32
} ) ;
31
33
} ) ;
Original file line number Diff line number Diff line change 11
11
<nav class =" flex items-center flex-row gap-2 mb-3 font-semibold" >
12
12
<span >Usage instructions for</span >
13
13
14
- <div >
15
- <input type =" checkbox" id =" usageDropdownInput" class =" hidden peer" />
16
-
17
- <label for =" usageDropdownInput" class =" flex gap-1 select-none cursor-pointer rounded border border-gray-300 py-2 px-3" >
14
+ <details id =" usageSelector" >
15
+ <summary class =" flex gap-1 select-none cursor-pointer rounded border border-gray-300 py-2 px-3" >
18
16
{{ ~#each usages ~}}
19
17
<div id =" {{ name }} _active_dropdown" class =" hidden items-center gap-1" >
20
18
<div class =" h-4 *:h-4 *:w-auto" >{{{ icon }}} {{! icon }} </div >
25
23
<div class =" rotate-90" >
26
24
{{~> icons/arrow }}
27
25
</div >
28
- </label >
26
+ </summary >
29
27
30
- <div class =" md:relative hidden peer-checked:block " id = " usageDropdown " >
28
+ <div class =" md:relative" >
31
29
<div class =" absolute max-md:inset-x-0 mt-1.5 p-2 block z-30 md:w-72 bg-white md:rounded border max-md:border-x-0 border-gray-300" >
32
30
{{ ~#each usages ~}}
33
31
<label for =" {{ name }} " class =" flex items-center justify-between cursor-pointer select-none px-2 py-1 leading-normal rounded-sm hover:bg-gray-50" >
38
36
{{ ~/each ~}}
39
37
</div >
40
38
</div >
41
- </div >
39
+ </details >
42
40
</nav >
43
41
{{ ~/if }}
44
42
You can’t perform that action at this time.
0 commit comments