@@ -55,6 +55,36 @@ export const CustomToggle = React.forwardRef(
55
55
)
56
56
)
57
57
58
+ // export const CustomInputToggle = React.forwardRef(
59
+ // (
60
+ // {
61
+ // children,
62
+ // onClick,
63
+ // icon,
64
+ // className = ''
65
+ // }: {
66
+ // children: React.ReactNode
67
+ // onClick: (e) => void
68
+ // icon: string
69
+ // className: string
70
+ // },
71
+ // ref: Ref<HTMLInputElement>
72
+ // ) => {
73
+ // const intl = useIntl()
74
+ // return (
75
+ // <input
76
+ // ref={ref}
77
+ // placeholder={intl.formatMessage({ id: "contract-verification.searchableChainDropdown", defaultMessage: "Select a chain" })}
78
+ // type="text"
79
+ // onClick={(e) => {
80
+ // e.preventDefault()
81
+ // onClick(e)
82
+ // }}
83
+ // className={className.replace('dropdown-toggle', '')}
84
+ // />
85
+ // )}
86
+ // )
87
+
58
88
export const SearchableChainDropdown : React . FC < DropdownProps > = ( { label, id, setSelectedChain, selectedChain } ) => {
59
89
const { chains } = React . useContext ( AppContext )
60
90
const ethereumChainIds = [ 1 , 11155111 , 17000 ]
@@ -126,21 +156,65 @@ export const SearchableChainDropdown: React.FC<DropdownProps> = ({ label, id, se
126
156
)
127
157
}
128
158
159
+ const CustomInputToggle = React . forwardRef (
160
+ (
161
+ {
162
+ children,
163
+ onClick,
164
+ icon,
165
+ className = ''
166
+ } : {
167
+ children : React . ReactNode
168
+ onClick : ( e ) => void
169
+ icon : string
170
+ className : string
171
+ } ,
172
+ ref : Ref < HTMLInputElement >
173
+ ) => {
174
+ const intl = useIntl ( )
175
+ return (
176
+ < input
177
+ ref = { ref }
178
+ placeholder = { intl . formatMessage ( { id : "contract-verification.searchableChainDropdown" , defaultMessage : "Select a chain" } ) }
179
+ type = "text"
180
+ onClick = { ( e ) => {
181
+ e . preventDefault ( )
182
+ onClick ( e )
183
+ } }
184
+ onChange = { handleInputChange }
185
+ value = { searchTerm }
186
+ className = { className . replace ( 'dropdown-toggle' , '' ) }
187
+ />
188
+ ) }
189
+ )
190
+
129
191
return (
130
- < Dropdown >
131
- < Dropdown . Toggle as = { CustomToggle } icon = { null } className = "btn btn-light border btn-block w-100 d-inline-block form-control" data-id = "chainDropdownbox" >
132
- { searchTerm . length > 0 ? searchTerm : intl . formatMessage ( { id : "contract-verification.searchableChainDropdown" , defaultMessage : "Select a chain" } ) }
133
- </ Dropdown . Toggle >
134
- < Dropdown . Menu className = "w-100 custom-dropdown-items border bg-light" >
192
+ < div className = "dropdown mb-3" ref = { dropdownRef } >
193
+ { ' ' }
194
+ { /* Add ref here */ }
195
+ < label htmlFor = { id } > { label } </ label >
196
+ < input
197
+ type = "text"
198
+ value = { searchTerm }
199
+ onChange = { handleInputChange }
200
+ onClick = { openDropdown }
201
+ data-id = "chainDropdownbox"
202
+ placeholder = { intl . formatMessage ( { id : "contract-verification.searchableChainDropdown" , defaultMessage : "Select a chain" } ) }
203
+ className = "form-control"
204
+ />
205
+ < ul className = "dropdown-menu custom-dropdown-items border bg-light show w-100" style = { { maxHeight : '400px' , overflowY : 'auto' , display : isOpen ? 'initial' : 'none' } } >
135
206
{ filteredOptions . map ( ( chain ) => (
136
- < Dropdown . Item key = { chain . chainId } onClick = { ( ) => handleOptionClick ( chain ) }
137
- className = { `${ getChainDescriptor ( chain ) . length > 30 ? 'text-truncate text-decoration-none' : 'text-decoration-none' } ` }
207
+ < li
208
+ key = { chain . chainId }
209
+ onClick = { ( ) => handleOptionClick ( chain ) }
138
210
data-id = { chain . chainId }
211
+ className = { `dropdown-item ${ selectedChain ?. chainId === chain . chainId ? 'active' : '' } ` }
212
+ style = { { cursor : 'pointer' , whiteSpace : 'normal' } }
139
213
>
140
214
{ getChainDescriptor ( chain ) }
141
- </ Dropdown . Item >
215
+ </ li >
142
216
) ) }
143
- </ Dropdown . Menu >
144
- </ Dropdown >
217
+ </ ul >
218
+ </ div >
145
219
)
146
220
}
0 commit comments