File tree Expand file tree Collapse file tree
plugins/openapi/src/react Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -979,7 +979,6 @@ export default function AddOpenApiSource(props: {
979979 onValueChange = { setBaseUrl }
980980 options = { baseUrlOptions }
981981 placeholder = "https://api.example.com"
982- emptyLabel = "Use the custom URL you typed."
983982 className = "w-full"
984983 inputClassName = "font-mono text-sm"
985984 />
Original file line number Diff line number Diff line change @@ -278,13 +278,16 @@ function FreeformCombobox(props: {
278278 readonly inputClassName ?: string ;
279279 readonly disabled ?: boolean ;
280280} ) {
281- const selectedValue = props . options . some ( ( option ) => option . value === props . value )
282- ? props . value
283- : null ;
281+ const valueOption = props . value . trim ( ) ;
282+ const options =
283+ valueOption . length > 0 && ! props . options . some ( ( option ) => option . value === valueOption )
284+ ? [ { value : valueOption , label : valueOption } , ...props . options ]
285+ : props . options ;
286+ const selectedValue = options . some ( ( option ) => option . value === props . value ) ? props . value : null ;
284287
285288 return (
286289 < Combobox
287- items = { props . options . map ( ( option ) => option . value ) }
290+ items = { options . map ( ( option ) => option . value ) }
288291 inputValue = { props . value }
289292 value = { selectedValue }
290293 onInputValueChange = { props . onValueChange }
@@ -302,7 +305,7 @@ function FreeformCombobox(props: {
302305 < ComboboxContent >
303306 < ComboboxEmpty > { props . emptyLabel ?? "No options" } </ ComboboxEmpty >
304307 < ComboboxList >
305- { props . options . map ( ( option ) => (
308+ { options . map ( ( option ) => (
306309 < ComboboxItem key = { option . value } value = { option . value } >
307310 < div className = "min-w-0 flex-1" >
308311 < div className = "truncate" > { option . label ?? option . value } </ div >
You can’t perform that action at this time.
0 commit comments