@@ -23,7 +23,7 @@ enum SortTypes {
23
23
24
24
export default function Sort ( ) {
25
25
const router = useRouter ( ) ;
26
- const [ isDisplay , setIsDisplay ] = useState < boolean > ( false ) ;
26
+ const [ isDisplay , setIsDisplay ] = useState < string > ( '' ) ;
27
27
28
28
const navigationItems = [
29
29
{
@@ -77,26 +77,28 @@ export default function Sort() {
77
77
return SortTypes . BestMatch ;
78
78
}
79
79
} ;
80
+
81
+ const handleClick = ( ) => {
82
+ const elem = document . activeElement as HTMLElement ;
83
+ if ( elem ) {
84
+ elem ?. blur ( ) ;
85
+ }
86
+ } ;
80
87
return (
81
88
< div className = "flex justify-center items-center mb-8 flex-col gap-2" >
82
89
< div className = "dropdown dropdown-hover" >
83
- < div onClick = { ( ) => setIsDisplay ( true ) } >
84
90
< Button tabIndex = { 0 } className = "m-1 py-2" >
85
91
< FontAwesomeIcon
86
92
icon = { faCode }
87
93
className = " w-6 h-6 mr-3"
88
94
> </ FontAwesomeIcon >
89
95
Language
90
96
</ Button >
91
- </ div >
92
97
< div
93
- className = { `h-64 p-2 overflow-y-scroll shadow dropdown-content z-50 bg-base-100 rounded-box w-60 ${
94
- ! isDisplay && 'hidden'
95
- } `}
96
- >
98
+ className = "h-64 p-2 overflow-y-scroll dropdown-content shadow z-50 bg-base-100 rounded-box w-60" >
97
99
< ul tabIndex = { 0 } className = "menu menu-vertical" >
98
100
{ mainLanguages . sort ( sortByName ) . map ( language => (
99
- < li key = { language } onClick = { ( ) => setIsDisplay ( false ) } >
101
+ < li key = { language } onClick = { handleClick } >
100
102
< Link href = { `/repos/${ language . toLowerCase ( ) } ` } >
101
103
{ language }
102
104
</ Link >
@@ -106,23 +108,18 @@ export default function Sort() {
106
108
</ div >
107
109
</ div >
108
110
< div className = "dropdown dropdown-hover" >
109
- < div onClick = { ( ) => setIsDisplay ( true ) } >
110
111
< Button tabIndex = { 0 } className = "py-2" >
111
112
< FontAwesomeIcon
112
113
icon = { faArrowUpAZ }
113
114
className = " w-6 h-6 mr-3"
114
115
> </ FontAwesomeIcon >
115
116
{ selectedSort ( ) }
116
117
</ Button >
117
- </ div >
118
118
< div
119
- className = { `h-64 p-2 z-50 overflow-y-scroll shadow dropdown-content bg-base-100 rounded-box w-60 ${
120
- ! isDisplay && 'hidden'
121
- } `}
122
- >
119
+ className = "h-64 p-2 z-50 overflow-y-scroll shadow dropdown-content bg-base-100 rounded-box w-60" >
123
120
< ul tabIndex = { 0 } className = "menu menu-vertical" >
124
121
{ navigationItems . map ( ( item , index ) => (
125
- < li key = { index } onClick = { ( ) => setIsDisplay ( false ) } >
122
+ < li key = { index } onClick = { handleClick } >
126
123
< Link href = { { query : item . href . query } } > { item . name } </ Link >
127
124
</ li >
128
125
) ) }
0 commit comments