measureLayout
relative to ScrollView
returns incorrect y
value
#2109
Labels
project:react-native-web
Issue associated with react-native-web
The problem
Calling
measureLayout
relative to aScrollView
returns the incorrecty
value when the scroll position is greater than 0.How to reproduce
Simplified test case: https://codesandbox.io/s/lucid-sea-rq0ny?file=/src/App.js:0-1339
Steps to reproduce:
measureLayout
.y
value returned frommeasureLayout
is incorrectly subtracting the current scroll position.To reproduce on your own:
ref: scrollRef
text inside of the ScrollView, give it a ref: textRef
. Put the text far down, maybe give it likemarginTop: 600
.textRef.current.measureLayout(scrollRef.current, callback)
and log the resultingy
value from the callback.ScrollView
, minus the scroll position.Expected behavior
The behavior should match that of native. Try the example on iOS here, and notice that it always scrolls to the correct spot: https://snack.expo.dev/@beatgig/dedc14
On native, calling
measureLayout
relative to aScrollView
gives they
coordinate relative to the top of the the scrollable content, regardless of scroll position.Environment (include versions). Did this work in previous versions?
0.17.0
17.0.2
It doesn't work in any previous versions, tried back to
0.15.x
, wheremeasureLayout
was initially implemented for ScrollViews (#1957).The text was updated successfully, but these errors were encountered: