11import cn from "classnames" ;
22import { useSelect , UseSelectProps } from "downshift" ;
33import { observer } from "mobx-react-lite" ;
4- import React , { createElement , useRef } from "react" ;
4+ import React , { createElement } from "react" ;
55import { OptionWithState } from "../../typings/OptionWithState" ;
66import { ClearButton } from "../base/ClearButton" ;
77import { OptionsWrapper } from "../base/OptionsWrapper" ;
@@ -18,15 +18,14 @@ interface SelectProps {
1818 style ?: React . CSSProperties ;
1919 useSelectProps : ( ) => UseSelectProps < OptionWithState > ;
2020 onClear : ( ) => void ;
21- onFocus ?: React . FocusEventHandler < HTMLButtonElement > ;
21+ onFocus ?: React . FocusEventHandler < HTMLDivElement > ;
2222 onMenuScroll ?: React . UIEventHandler < HTMLUListElement > ;
2323}
2424
2525const cls = classes ( ) ;
2626
2727export const Select = observer ( function Select ( props : SelectProps ) : React . ReactElement {
2828 const { empty : isEmpty , showCheckboxes, clearable } = props ;
29- const toggleRef = useRef < HTMLButtonElement > ( null ) ;
3029 const { getToggleButtonProps, getMenuProps, getItemProps, isOpen, highlightedIndex } = useSelect (
3130 props . useSelectProps ( )
3231 ) ;
@@ -37,25 +36,22 @@ export const Select = observer(function Select(props: SelectProps): React.ReactE
3736 return (
3837 < div
3938 className = { cn ( cls . root , "form-control" , "variant-select" , props . className ) }
40- ref = { refs . setReference }
4139 data-expanded = { isOpen }
4240 data-empty = { isEmpty ? true : undefined }
4341 style = { props . style }
42+ { ...getToggleButtonProps ( {
43+ "aria-label" : props . value ,
44+ ref : refs . setReference ,
45+ onFocus : props . onFocus
46+ } ) }
4447 >
45- < button
46- className = { cls . inputContainer }
47- { ...getToggleButtonProps ( {
48- "aria-label" : props . value ,
49- ref : toggleRef ,
50- onFocus : props . onFocus
51- } ) }
52- >
48+ < div className = { cls . inputContainer } >
5349 < span className = { cls . toggle } > { props . value } </ span >
5450 < div className = { `${ cls . root } -controls` } >
5551 < ClearButton cls = { cls } onClick = { props . onClear } visible = { showClear } />
5652 < Arrow className = { cls . stateIcon } />
5753 </ div >
58- </ button >
54+ </ div >
5955 < OptionsWrapper
6056 cls = { cls }
6157 ref = { refs . setFloating }
0 commit comments