Skip to content

Commit 03b8b8d

Browse files
fix(multi-org): typeahead dropdown hugs the item's list (#5376)
1 parent fae2c0b commit 03b8b8d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/identity/components/GlobalHeader/GlobalHeaderDropdown/GlobalHeaderTypeAheadMenu.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ type State = {
1919
}
2020

2121
export 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}

0 commit comments

Comments
 (0)