@@ -13,6 +13,7 @@ import React, {useEffect} from 'react';
1313import type { AutoCompleteSuggestionsProps , MeasureParentContainerAndCursor } from './types' ;
1414
1515import AutoCompleteSuggestionsPortal from './AutoCompleteSuggestionsPortal' ;
16+ import getBottomSuggestionPadding from './AutoCompleteSuggestionsPortal/getBottomSuggestionPadding' ;
1617import getLeftOffset from './getSuggestionsLeftOffset' ;
1718import getSuggestionsViewportBottom from './getSuggestionsViewportBottom' ;
1819
@@ -43,11 +44,13 @@ function isSuggestionMenuRenderedAbove(isEnoughSpaceAboveForBigMenu: boolean, is
4344}
4445
4546type IsEnoughSpaceToRenderMenuAboveCursor = Pick < MeasureParentContainerAndCursor , 'y' | 'cursorCoordinates' | 'scrollValue' > & {
46- contentHeight : number ;
47+ menuHeight : number ;
4748 topInset : number ;
4849} ;
49- function isEnoughSpaceToRenderMenuAboveCursor ( { y, cursorCoordinates, scrollValue, contentHeight, topInset} : IsEnoughSpaceToRenderMenuAboveCursor ) : boolean {
50- return y + ( cursorCoordinates . y - scrollValue ) > contentHeight + topInset + CONST . AUTO_COMPLETE_SUGGESTER . SUGGESTION_BOX_MAX_SAFE_DISTANCE ;
50+ function isEnoughSpaceToRenderMenuAboveCursor ( { y, cursorCoordinates, scrollValue, menuHeight, topInset} : IsEnoughSpaceToRenderMenuAboveCursor ) : boolean {
51+ const gapAboveCursor = Math . max ( CONST . AUTO_COMPLETE_SUGGESTER . SUGGESTION_BOX_MAX_SAFE_DISTANCE , getBottomSuggestionPadding ( true ) ) ;
52+
53+ return y + ( cursorCoordinates . y - scrollValue ) > menuHeight + gapAboveCursor + topInset ;
5154}
5255
5356const initialContainerState = {
@@ -123,7 +126,7 @@ function AutoCompleteSuggestions<TSuggestion>({measureParentContainerAndReportCu
123126 y,
124127 cursorCoordinates,
125128 scrollValue,
126- contentHeight : contentMaxHeight ,
129+ menuHeight : StyleUtils . getAutoCompleteSuggestionContainerHeight ( contentMaxHeight ) ,
127130 topInset,
128131 } ) ;
129132
@@ -134,7 +137,7 @@ function AutoCompleteSuggestions<TSuggestion>({measureParentContainerAndReportCu
134137 y,
135138 cursorCoordinates,
136139 scrollValue,
137- contentHeight : contentMinHeight ,
140+ menuHeight : StyleUtils . getAutoCompleteSuggestionContainerHeight ( contentMinHeight ) ,
138141 topInset,
139142 } ) ;
140143
@@ -186,6 +189,7 @@ function AutoCompleteSuggestions<TSuggestion>({measureParentContainerAndReportCu
186189 isKeyboardAnimatingRef ,
187190 isInLandscapeMode ,
188191 insets ,
192+ StyleUtils ,
189193 ] ) ;
190194
191195 // Prevent rendering if container dimensions are not set or if we have no suggestions
0 commit comments