View in Flatlist outputs incorrect 'x' and 'y' origin position in Android
Description
Appears on Android only: Using a view in RN 0.61.5 and above within a flat list is displayed correctly. However, when getting the location of the view using the following Java code:
int[] location = new int[2];
myView.getLocationOnScreen(location);
results in incorrect values (x=0,y=0).
When adding the removeClippedSubviews={false} (even though the default value in the documentation is false) flag to the Flatlist, the output is correct (x=10, y=1216).
The behavior works correctly on iOS without the need to add the flag.
React Native version:
Appears on 0.61.5 and above, including the latest version. Works fine on 0.59.10.
Steps To Reproduce
Using the following below example to reproduce:
const FlatListTester = props => {
const p1 = <Text key="p1">{paragraphs[0]}</Text>;
const p2 = <Text key="p2">{paragraphs[1]}</Text>;
const p3 = <Text style={styles.middle} key="p3">{paragraphs[2]}</Text>;
const p4 = <Text key="p4">{paragraphs[3]}</Text>;
return (
<Container>
<View>
<FlatList
data={[{ key: 'p1' }, { key: 'p2' }, { key: 'p3' }, { key: 'p4' }, { key: 'myview' }]}
renderItem={({ item }) => {
switch (item.key) {
case 'p1':
return p1;
case 'p2':
return p2;
case 'p3':
return p3;
case 'p4':
return p4;
case 'myview':
return <MyView />;
default:
return null;
}
}}
/>
</View>
</Container>
);
Expected Results
As in description, provide the correct origin (x=10, y=1216) when using myView.getLocationOnScreen(location);
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.