@@ -19,8 +19,10 @@ const defaultOptionGroupRenderer = (title: string) => title;
19
19
20
20
const defaultMenuRenderer : Dropdown . MenuRendererHandler = ( {
21
21
focusedOption,
22
+ focusOption,
22
23
instancePrefix,
23
24
onFocus,
25
+ onOptionRef,
24
26
onSelect,
25
27
groupByKey,
26
28
optionClassName,
@@ -63,7 +65,6 @@ const defaultMenuRenderer: Dropdown.MenuRendererHandler = ({
63
65
{ optionGroup . map ( ( option , i ) => {
64
66
const isSelected = valueArray && valueArray . indexOf ( option ) > - 1 ;
65
67
const isFocused = option === focusedOption ;
66
- const optionRef = isFocused ? 'focused' : null ;
67
68
const optionClass = cx ( optionClassName , {
68
69
'Select-option' : true ,
69
70
'is-selected' : isSelected ,
@@ -73,6 +74,7 @@ const defaultMenuRenderer: Dropdown.MenuRendererHandler = ({
73
74
return (
74
75
< OptionComponent
75
76
className = { optionClass }
77
+ focusOption = { focusOption }
76
78
instancePrefix = { instancePrefix }
77
79
isDisabled = { option . disabled }
78
80
isFocused = { isFocused }
@@ -82,7 +84,7 @@ const defaultMenuRenderer: Dropdown.MenuRendererHandler = ({
82
84
onSelect = { onSelect }
83
85
option = { option }
84
86
optionIndex = { i }
85
- ref = { optionRef }
87
+ ref = { ( ref : React . Component < Dropdown . Props > | null ) => { onOptionRef ( ref , isFocused ) ; } }
86
88
>
87
89
{ optionRenderer ( option , i ) }
88
90
</ OptionComponent >
@@ -213,6 +215,7 @@ export namespace Dropdown {
213
215
// seem supported by react-select but missing in the @types file?
214
216
instancePrefix ?: string
215
217
onFocus ?: ( ) => void
218
+ onOptionRef : ( ref : React . Component < Dropdown . Props > | null , isFocused : boolean ) => void
216
219
onSelect ?: ( ) => void
217
220
optionClassName ?: string
218
221
optionComponent : React . ComponentType < { [ k : string ] : any } > // TODO
0 commit comments