1- import { Link } from "@commons-ui/next" ;
21import {
32 IconButton ,
43 InputBase ,
@@ -37,9 +36,26 @@ function DropdownSearch({
3736 setSelectedLocation ( null ) ;
3837 } ;
3938
39+ const handleClickSearch = ( ) => {
40+ if ( onClick ) {
41+ onClick ( selectedLocation ) ;
42+ } else if ( selectedLocation ) {
43+ const href = `${ hrefProp } /${ selectedLocation } ` ;
44+ router . push ( href ) ;
45+ } else if ( query ) {
46+ router . push ( "/404" ) ;
47+ }
48+ } ;
49+
4050 const handleSelect = ( code , name ) => {
4151 setQuery ( name . toLowerCase ( ) ) ;
4252 setSelectedLocation ( code ) ;
53+ if ( onClick ) {
54+ onClick ( code ) ;
55+ } else {
56+ const href = `${ hrefProp } /${ code } ` ;
57+ router . push ( href ) ;
58+ }
4359 } ;
4460
4561 useEffect ( ( ) => {
@@ -53,17 +69,6 @@ function DropdownSearch({
5369 }
5470 } , [ locations , selectedLocation , query ] ) ;
5571
56- const handleClickSearch = ( ) => {
57- if ( onClick ) {
58- onClick ( selectedLocation ) ;
59- } else if ( selectedLocation ) {
60- const href = `${ hrefProp } /${ selectedLocation } ` ;
61- router . push ( href ) ;
62- } else if ( query ) {
63- router . push ( "/404" ) ;
64- }
65- } ;
66-
6772 let iconComponent = SearchIcon ;
6873 let iconBorder ;
6974 if ( variant === "explore" ) {
@@ -171,14 +176,13 @@ function DropdownSearch({
171176 >
172177 { suggestions . map ( ( { name, code } ) => (
173178 < ListItem
174- component = { Link }
175- href = { `${ hrefProp } /${ code } ` }
176179 variant = "subtitle1"
177180 underline = "none"
178181 onClick = { ( ) => handleSelect ( code , name ) }
179182 sx = { ( { typography, palette } ) => ( {
180183 paddingLeft : typography . pxToRem ( 20 ) ,
181184 color : palette . text . hint ,
185+ cursor : "pointer" ,
182186 } ) }
183187 key = { code }
184188 >
0 commit comments