@@ -45,6 +45,7 @@ export const AutocompleteDropdownContextProvider: FC<IAutocompleteDropdownContex
45
45
undefined ,
46
46
)
47
47
const activeInputContainerRef = useRef < View > ( null )
48
+ const wrapperRef = useRef < View > ( null )
48
49
const activeControllerRef = useRef < IAutocompleteDropdownRef | null > ( null )
49
50
const controllerRefs = useRef < IAutocompleteDropdownRef [ ] > ( [ ] )
50
51
const positionTrackingIntervalRef = useRef < NodeJS . Timeout > ( )
@@ -83,8 +84,10 @@ export const AutocompleteDropdownContextProvider: FC<IAutocompleteDropdownContex
83
84
useEffect ( ( ) => {
84
85
if ( content ) {
85
86
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
+ } )
88
91
} )
89
92
} else {
90
93
setInputMeasurements ( undefined )
@@ -99,12 +102,14 @@ export const AutocompleteDropdownContextProvider: FC<IAutocompleteDropdownContex
99
102
if ( show && ! ! opacity ) {
100
103
positionTrackingIntervalRef . current = setInterval ( ( ) => {
101
104
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 }
104
108
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 ,
106
110
)
107
111
} )
112
+ } )
108
113
} )
109
114
} , 16 )
110
115
} else {
@@ -132,6 +137,7 @@ export const AutocompleteDropdownContextProvider: FC<IAutocompleteDropdownContex
132
137
controllerRefs,
133
138
} } >
134
139
< View
140
+ ref = { wrapperRef }
135
141
style = { styles . clickOutsideHandlerArea }
136
142
onTouchEnd = { ( ) => {
137
143
activeControllerRef . current ?. close ( )
0 commit comments