@@ -7,6 +7,7 @@ import useWindowDimensionsForAutoCompleteSuggestions from '@hooks/useWindowDimen
77import { hasHoverSupport } from '@libs/DeviceCapabilities' ;
88import CONST from '@src/CONST' ;
99import AutoCompleteSuggestionsPortal from './AutoCompleteSuggestionsPortal' ;
10+ import getLeftOffset from './getSuggestionsLeftOffset' ;
1011import type { AutoCompleteSuggestionsProps , MeasureParentContainerAndCursor } from './types' ;
1112
1213const measureHeightOfSuggestionRows = ( numRows : number , canBeBig : boolean , isInLandscapeMode : boolean ) : number => {
@@ -50,13 +51,6 @@ const initialContainerState = {
5051 cursorCoordinates : { x : 0 , y : 0 } ,
5152} ;
5253
53- function getLeftOffset ( x : number , leftInset : number , bigScreenLeftOffset : number , shouldUseNarrowLayout : boolean , isInLandscapeMode : boolean ) : number {
54- if ( shouldUseNarrowLayout ) {
55- return isInLandscapeMode ? x - leftInset : x ;
56- }
57- return bigScreenLeftOffset ;
58- }
59-
6054/**
6155 * On the mobile-web platform, when long-pressing on auto-complete suggestions,
6256 * we need to prevent focus shifting to avoid blurring the main input (which makes the suggestions picker close and fires the onSelect callback).
@@ -78,7 +72,6 @@ function AutoCompleteSuggestions<TSuggestion>({measureParentContainerAndReportCu
7872 const insets = useSafeAreaInsets ( ) ;
7973 const { keyboardHeight, isKeyboardAnimatingRef} = useKeyboardState ( ) ;
8074 const { paddingBottom : bottomInset , paddingTop : topInset } = StyleUtils . getPlatformSafeAreaPadding ( insets ?? undefined ) ;
81- const { left : leftInset } = insets ;
8275
8376 useEffect ( ( ) => {
8477 const container = containerRef . current ;
@@ -136,7 +129,7 @@ function AutoCompleteSuggestions<TSuggestion>({measureParentContainerAndReportCu
136129 topInset,
137130 } ) ;
138131
139- const newLeftOffset = getLeftOffset ( x , leftInset , bigScreenLeftOffset , shouldUseNarrowLayout , isInLandscapeMode ) ;
132+ const newLeftOffset = getLeftOffset ( x , insets , bigScreenLeftOffset , shouldUseNarrowLayout , width , windowWidth , isInLandscapeMode ) ;
140133 // If the suggested word is longer than 150 (approximately half the width of the suggestion popup), then adjust a new position of popup
141134 const isAdjustmentNeeded = Math . abs ( prevLeftValue . current - bigScreenLeftOffset ) > 150 ;
142135 if ( isInitialRender . current || isAdjustmentNeeded || prevIsInLandscapeModeValue . current !== isInLandscapeMode ) {
@@ -179,7 +172,7 @@ function AutoCompleteSuggestions<TSuggestion>({measureParentContainerAndReportCu
179172 topInset ,
180173 isKeyboardAnimatingRef ,
181174 isInLandscapeMode ,
182- leftInset ,
175+ insets ,
183176 ] ) ;
184177
185178 // Prevent rendering if container dimensions are not set or if we have no suggestions
0 commit comments