Skip to content

Commit f0dfd31

Browse files
committed
update height calculation for signle/multi select popup to match user select popup
1 parent 4d41270 commit f0dfd31

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

src/components/Search/FilterDropdowns/MultiSelectPopup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function MultiSelectPopup<T extends string>({label, value, items, closeOverlay,
7878
<View style={[!isSmallScreenWidth && styles.pv4, styles.gap2]}>
7979
{isSmallScreenWidth && <Text style={[styles.textLabel, styles.textSupporting, styles.ph5, styles.pv1]}>{label}</Text>}
8080

81-
<View style={[styles.getSelectionListPopoverHeight(items.length, windowHeight)]}>
81+
<View style={[styles.getSelectionListPopoverHeight(items.length, windowHeight, false)]}>
8282
<SelectionList
8383
shouldSingleExecuteRowSelect
8484
sections={[{data: listData}]}

src/components/Search/FilterDropdowns/SingleSelectPopup.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ function SingleSelectPopup<T extends string>({label, value, items, closeOverlay,
9595
};
9696
}, [isSearchable, items, value, selectedItem, debouncedSearchTerm]);
9797

98+
const dataLength = useMemo(() => sections.flatMap((section) => section.data).length, [sections]);
99+
98100
const updateSelectedItem = useCallback(
99101
(item: ListItem) => {
100102
const newItem = items.find((i) => i.value === item.keyForList) ?? null;
@@ -117,7 +119,7 @@ function SingleSelectPopup<T extends string>({label, value, items, closeOverlay,
117119
<View style={[!isSmallScreenWidth && styles.pv4, styles.gap2]}>
118120
{isSmallScreenWidth && <Text style={[styles.textLabel, styles.textSupporting, styles.ph5, styles.pv1]}>{label}</Text>}
119121

120-
<View style={[styles.getSelectionListPopoverHeight(items.length, windowHeight)]}>
122+
<View style={[styles.getSelectionListPopoverHeight(dataLength || 1, windowHeight, isSearchable ?? false)]}>
121123
<SelectionList
122124
shouldSingleExecuteRowSelect
123125
sections={sections}

src/styles/index.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5636,12 +5636,22 @@ const styles = (theme: ThemeColors) =>
56365636
marginBottom: 20,
56375637
}),
56385638

5639-
getSelectionListPopoverHeight: (itemCount: number, windowHeight: number) => ({
5639+
getSelectionListPopoverHeight: (itemCount: number, windowHeight: number, isSearchable: boolean) => {
5640+
const SEARCHBAR_HEIGHT = isSearchable ? 52 : 0;
5641+
const SEARCHBAR_PADDING = isSearchable ? 12 : 0;
5642+
const PADDING = 32;
5643+
const GAP = 8;
5644+
const BUTTON_HEIGHT = 40;
5645+
const ESTIMATED_LIST_HEIGHT = itemCount * variables.optionRowHeightCompact + SEARCHBAR_HEIGHT + SEARCHBAR_PADDING;
5646+
const MAX_HEIGHT = CONST.POPOVER_DROPDOWN_MAX_HEIGHT - (PADDING + GAP + BUTTON_HEIGHT);
5647+
56405648
// Native platforms don't support maxHeight in the way thats expected, so lets manually set the height to either
56415649
// the listHeight, the max height of the popover, or 90% of the window height, such that we never overflow the screen
56425650
// and never expand over the max height
5643-
height: Math.min(itemCount * variables.optionRowHeightCompact, CONST.POPOVER_DROPDOWN_MAX_HEIGHT, windowHeight * 0.9),
5644-
}),
5651+
const height = Math.min(ESTIMATED_LIST_HEIGHT, MAX_HEIGHT, windowHeight * 0.9);
5652+
5653+
return {height};
5654+
},
56455655

56465656
getUserSelectionListPopoverHeight: (itemCount: number, windowHeight: number, shouldUseNarrowLayout: boolean) => {
56475657
const BUTTON_HEIGHT = 40;

0 commit comments

Comments
 (0)