File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ type State = {
1919}
2020
2121export class GlobalHeaderTypeAheadMenu extends React . Component < Props , State > {
22+ private listItemHeight = 50
23+ private maxDropdownHeight = 150
2224 constructor ( props : Props ) {
2325 super ( props )
2426 this . state = {
@@ -82,6 +84,9 @@ export class GlobalHeaderTypeAheadMenu extends React.Component<Props, State> {
8284 }
8385 }
8486
87+ private calculateDropdownHeight = ( numberOfItems : number ) =>
88+ Math . min ( numberOfItems * this . listItemHeight , this . maxDropdownHeight )
89+
8590 render ( ) {
8691 const { typeAheadPlaceHolder = 'Type here to search' , style} = this . props
8792 const { searchTerm, queryResults, selectedItem} = this . state
@@ -103,9 +108,11 @@ export class GlobalHeaderTypeAheadMenu extends React.Component<Props, State> {
103108 { filterSearchInput }
104109 { queryResults && queryResults . length > 0 ? (
105110 < List
106- height = { style ?. height ?? 150 }
111+ height = {
112+ style ?. height ?? this . calculateDropdownHeight ( queryResults . length )
113+ }
107114 itemCount = { queryResults . length }
108- itemSize = { 50 }
115+ itemSize = { this . listItemHeight }
109116 width = "100%"
110117 layout = "vertical"
111118 itemData = { queryResults }
You can’t perform that action at this time.
0 commit comments