File tree 2 files changed +15
-6
lines changed
2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @near-pagoda/ui" ,
3
- "version" : " 3.2.2 " ,
3
+ "version" : " 3.2.3 " ,
4
4
"description" : " A React component library that implements the official NEAR design system." ,
5
5
"license" : " MIT" ,
6
6
"repository" : {
Original file line number Diff line number Diff line change @@ -83,21 +83,30 @@ export const Combobox = forwardRef<HTMLInputElement, Props>(
83
83
onInputValueChange ( event ) {
84
84
const query = event . inputValue ?. toLowerCase ( ) ?? '' ;
85
85
const options = allowNone ? [ noneOption , ...props . options ] : props . options ;
86
+
86
87
const results = options . filter ( ( o ) => {
87
88
if ( o . hidden ) return false ;
88
89
const label = ( o . label ?? o . value ) . toString ( ) . toLowerCase ( ) ;
89
90
return label . includes ( query ) ;
90
91
} ) ;
92
+
91
93
setFilteredItems ( results ) ;
92
94
93
- if ( allowCustomInput ) {
94
- props . onChange ( event . inputValue || internalCurrentValueBeforeFocus . current || '' ) ;
95
- console . log ( 'onInputValueChange' , event . inputValue ?? '' ) ;
95
+ if ( allowCustomInput && event . inputValue ) {
96
+ const selected = results . find ( ( option ) => ( option . label || option . value ) === event . inputValue ) ;
97
+ if ( selected ) {
98
+ if ( selected . value !== props . value ) {
99
+ props . onChange ( selected . value ) ;
100
+ }
101
+ } else {
102
+ if ( event . selectedItem ) {
103
+ selectItem ( null ) ;
104
+ }
105
+ props . onChange ( event . inputValue ) ;
106
+ }
96
107
}
97
108
} ,
98
109
onSelectedItemChange ( event ) {
99
- console . log ( 'onSelectedItemChange' , event ) ;
100
-
101
110
const newValue = event . selectedItem ?. value === '__NONE__' ? null : ( event . selectedItem ?. value ?? null ) ;
102
111
internalCurrentValue . current = newValue ;
103
112
You can’t perform that action at this time.
0 commit comments