Report initial offset of horizontal scroll view to Fabric

Summary:
Changelog: [internal]

Calling `scrollTo` does not report offset change to Fabric core and measure infra can't compute correct values. This results in unresponsive buttons if horizontal scroll view on Android has initial offset set to anything besides default value 0.

Reviewed By: JoshuaGross

Differential Revision: D26778991

fbshipit-source-id: 5cad5cb9926c7923f6efcd56cb4e15c3b958c245
This commit is contained in:
Samuel Susla
2021-03-03 13:05:22 -08:00
committed by Facebook GitHub Bot
parent 84a81dac13
commit 630ac87591
@@ -8,7 +8,6 @@
package com.facebook.react.views.scroll;
import android.content.Context;
import android.widget.HorizontalScrollView;
import androidx.core.view.ViewCompat;
import com.facebook.react.modules.i18nmanager.I18nUtil;
import com.facebook.react.views.view.ReactViewGroup;
@@ -40,10 +39,10 @@ public class ReactHorizontalScrollContainerView extends ReactViewGroup {
setRight(newRight);
// Call with the present values in order to re-layout if necessary
HorizontalScrollView parent = (HorizontalScrollView) getParent();
ReactHorizontalScrollView parent = (ReactHorizontalScrollView) getParent();
// Fix the ScrollX position when using RTL language
int offsetX = parent.getScrollX() + getWidth() - mCurrentWidth;
parent.scrollTo(offsetX, parent.getScrollY());
parent.reactScrollTo(offsetX, parent.getScrollY());
}
mCurrentWidth = getWidth();
}