@@ -57,6 +57,8 @@ export type ValueType = any;
57
57
export interface InputPickerProps < T = ValueType >
58
58
extends FormControlPickerProps < T , InputPickerLocale , InputItemDataType > ,
59
59
SelectProps < T > {
60
+ tabIndex ?: number ;
61
+
60
62
multi ?: boolean ;
61
63
62
64
/** Settings can create new options */
@@ -126,6 +128,7 @@ const InputPicker: PickerComponent<InputPickerProps> = React.forwardRef(
126
128
labelKey,
127
129
listProps,
128
130
id,
131
+ tabIndex,
129
132
sort,
130
133
renderMenu,
131
134
renderExtraFooter,
@@ -164,8 +167,6 @@ const InputPicker: PickerComponent<InputPickerProps> = React.forwardRef(
164
167
const [ maxWidth , setMaxWidth ] = useState ( 100 ) ;
165
168
const [ newData , setNewData ] = useState ( [ ] ) ;
166
169
const [ uncontrolledOpen , setOpen ] = useState ( defaultOpen ) ;
167
- // Use component active state to support keyboard events.
168
- const [ active , setActive ] = useState ( false ) ;
169
170
const open = isUndefined ( controlledOpen ) ? uncontrolledOpen : controlledOpen ;
170
171
171
172
const getAllData = useCallback ( ( ) => [ ] . concat ( uncontrolledData , newData ) , [
@@ -516,11 +517,12 @@ const InputPicker: PickerComponent<InputPickerProps> = React.forwardRef(
516
517
} , [ setFocusItemValue , setSearchKeyword , onClose , value , multi ] ) ;
517
518
518
519
const handleFocus = useCallback ( ( ) => {
519
- setActive ( true ) ;
520
+ setOpen ( true ) ;
521
+ triggerRef . current ?. open ( ) ;
520
522
} , [ ] ) ;
521
523
522
524
const handleBlur = useCallback ( ( ) => {
523
- setActive ( false ) ;
525
+ setOpen ( false ) ;
524
526
} , [ ] ) ;
525
527
526
528
const handleEnter = useCallback ( ( ) => {
@@ -675,7 +677,7 @@ const InputPicker: PickerComponent<InputPickerProps> = React.forwardRef(
675
677
676
678
const classes = merge ( pickerClasses , {
677
679
[ prefix `tag` ] : multi ,
678
- [ prefix `focused` ] : open || active
680
+ [ prefix `focused` ] : open
679
681
} ) ;
680
682
const searching = ! ! searchKeyword && open ;
681
683
const displaySearchInput = searchable && ! disabled ;
@@ -721,7 +723,7 @@ const InputPicker: PickerComponent<InputPickerProps> = React.forwardRef(
721
723
onClean = { handleClean }
722
724
cleanable = { cleanable && ! disabled }
723
725
hasValue = { hasValue }
724
- active = { active }
726
+ active = { open }
725
727
disabled = { disabled }
726
728
placement = { placement }
727
729
inputValue = { value }
@@ -733,6 +735,7 @@ const InputPicker: PickerComponent<InputPickerProps> = React.forwardRef(
733
735
{ displaySearchInput && (
734
736
< InputSearch
735
737
{ ...inputProps }
738
+ tabIndex = { tabIndex }
736
739
readOnly = { readOnly }
737
740
onBlur = { createChainedFunction ( handleBlur , onBlur ) }
738
741
onFocus = { createChainedFunction ( handleFocus , onFocus ) }
0 commit comments