Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public class ReactEditText extends AppCompatEditText {
private boolean mContextMenuHidden = false;
private boolean mDidAttachToWindow = false;
private boolean mSelectTextOnFocus = false;
private boolean mDidSelectTextOnFocus = false;
private @Nullable String mPlaceholder = null;
private Overflow mOverflow = Overflow.VISIBLE;

Expand Down Expand Up @@ -250,11 +251,11 @@ public boolean isLayoutRequested() {
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
onContentSizeChange();
if (mSelectTextOnFocus && isFocused()) {
if (mSelectTextOnFocus && isFocused() && !mDidSelectTextOnFocus) {
// Explicitly call this method to select text when layout is drawn
selectAll();
// Prevent text on being selected for next layout pass
mSelectTextOnFocus = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there other cases in Reanimated where props are reapplied multiple times? There are other places where that will cause problems, e.g. for ScrollView setting the contentOffset prop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not strictly Reanimated reapplying props - it's this part of the code:

if (!hasBeenMounted && sourceNodeHasRawProps && props) {
auto& castedProps = const_cast<Props&>(*props);
castedProps.rawProps = mergeDynamicProps(
sourceShadowNode.getProps()->rawProps,
props->rawProps,
NullValueStrategy::Override);
return props;

which relies on the previous node being mounted to apply only the props diff. This assumption is broken by Reanimated at the moment, but it's going to be fixed in the future. I think wrong behavior here was caused by the same field being used to store a prop and the view state at the same time.

mDidSelectTextOnFocus = true;
}
}

Expand Down Expand Up @@ -630,6 +631,7 @@ public void maybeUpdateTypeface() {
// VisibleForTesting from {@link TextInputEventsTestCase}.
public void requestFocusFromJS() {
requestFocusInternal();
mDidSelectTextOnFocus = true;
}

/* package */ void clearFocusFromJS() {
Expand Down