@@ -45,6 +45,7 @@ export const AutocompleteDropdownContextProvider: FC<IAutocompleteDropdownContex
4545 undefined ,
4646 )
4747 const activeInputContainerRef = useRef < View > ( null )
48+ const wrapperRef = useRef < View > ( null )
4849 const activeControllerRef = useRef < IAutocompleteDropdownRef | null > ( null )
4950 const controllerRefs = useRef < IAutocompleteDropdownRef [ ] > ( [ ] )
5051 const positionTrackingIntervalRef = useRef < NodeJS . Timeout > ( )
@@ -83,8 +84,10 @@ export const AutocompleteDropdownContextProvider: FC<IAutocompleteDropdownContex
8384 useEffect ( ( ) => {
8485 if ( content ) {
8586 activeInputContainerRef ?. current ?. measure ( ( x , y , width , height , pageX , pageY ) => {
86- setInputMeasurements ( { x : pageX , y : pageY , width, height } )
87- setShow ( true )
87+ wrapperRef . current ?. measure ( ( wrapperX , wrapperY , wrapperW , wrapperH , wrapperPageX , wrapperPageY ) => {
88+ setInputMeasurements ( { x : pageX , y : pageY - wrapperPageY , width, height } )
89+ setShow ( true )
90+ } )
8891 } )
8992 } else {
9093 setInputMeasurements ( undefined )
@@ -99,12 +102,14 @@ export const AutocompleteDropdownContextProvider: FC<IAutocompleteDropdownContex
99102 if ( show && ! ! opacity ) {
100103 positionTrackingIntervalRef . current = setInterval ( ( ) => {
101104 requestAnimationFrame ( ( ) => {
102- activeInputContainerRef ?. current &&
103- activeInputContainerRef ?. current ?. measure ( ( _x , _y , width , height , x , y ) => {
105+ activeInputContainerRef ?. current ?. measure ( ( _x , _y , width , height , inputPageX , inputPageY ) => {
106+ wrapperRef . current ?. measure ( ( wrapperX , wrapperY , wrapperW , wrapperH , wrapperPageX , wrapperPageY ) => {
107+ const currentMeasurement = { x : inputPageX , y : inputPageY - wrapperPageY , width, height }
104108 setInputMeasurements ( prev =>
105- JSON . stringify ( prev ) === JSON . stringify ( { x , y , width , height } ) ? prev : { x , y , width , height } ,
109+ JSON . stringify ( prev ) === JSON . stringify ( currentMeasurement ) ? prev : currentMeasurement ,
106110 )
107111 } )
112+ } )
108113 } )
109114 } , 16 )
110115 } else {
@@ -132,6 +137,7 @@ export const AutocompleteDropdownContextProvider: FC<IAutocompleteDropdownContex
132137 controllerRefs,
133138 } } >
134139 < View
140+ ref = { wrapperRef }
135141 style = { styles . clickOutsideHandlerArea }
136142 onTouchEnd = { ( ) => {
137143 activeControllerRef . current ?. close ( )
0 commit comments