@@ -53,6 +53,7 @@ export const SELECT_COMPONENT_CONTAINER = 'select-component-container';
53
53
export class SelectComponent extends React . Component < SelectComponentProps , SelectComponentState > {
54
54
protected dropdownElement : HTMLElement ;
55
55
protected fieldRef = React . createRef < HTMLDivElement > ( ) ;
56
+ protected dropdownRef = React . createRef < HTMLDivElement > ( ) ;
56
57
protected mountedListeners : Map < string , EventListenerOrEventListenerObject > = new Map ( ) ;
57
58
protected optimalWidth = 0 ;
58
59
protected optimalHeight = 0 ;
@@ -124,8 +125,10 @@ export class SelectComponent extends React.Component<SelectComponentProps, Selec
124
125
}
125
126
126
127
protected attachListeners ( ) : void {
127
- const hide = ( ) => {
128
- this . hide ( ) ;
128
+ const hide = ( event : MouseEvent ) => {
129
+ if ( ! this . dropdownRef . current ?. contains ( event . target as Node ) ) {
130
+ this . hide ( ) ;
131
+ }
129
132
} ;
130
133
this . mountedListeners . set ( 'scroll' , hide ) ;
131
134
this . mountedListeners . set ( 'wheel' , hide ) ;
@@ -317,8 +320,9 @@ export class SelectComponent extends React.Component<SelectComponentProps, Selec
317
320
bottom : invert ? clientRect . top + clientRect . height - this . state . dimensions . top : 'none' ,
318
321
left : this . state . dimensions . left ,
319
322
width : Math . min ( calculatedWidth , maxWidth ) ,
323
+ maxHeight : clientRect . height - ( invert ? clientRect . height - this . state . dimensions . bottom : this . state . dimensions . top ) - this . state . dimensions . height ,
320
324
position : 'absolute'
321
- } } >
325
+ } } ref = { this . dropdownRef } >
322
326
{ items }
323
327
</ div > ;
324
328
}
0 commit comments