Comparison of AttributedString false more often than true in TextInput, resulting in janky editing behavior

Summary:
Instead of comparing the entire AttributedString, compare just the strings and the TextAttributes of Fragments.

Concretely what I'm seeing is that the Frame of the associated parent ShadowViews are changing very frequently, making it impossible to actually modify the TextInput in some cases. However, we shouldn't forcibly reset the content of the TextInput if the frame of the parent is changing and not the actual child contents.

Changelog: [Internal] Fabric TextInput bug fix

Reviewed By: shergin

Differential Revision: D20319359

fbshipit-source-id: 2f51f521ad76fff9da6f6c8b5e795f03c33e496f
This commit is contained in:
Joshua Gross
2020-03-06 19:37:27 -08:00
committed by Facebook Github Bot
parent 074a2fab74
commit c18cc76e58
3 changed files with 31 additions and 3 deletions
@@ -94,10 +94,17 @@ AttributedString AndroidTextInputShadowNode::getMostRecentAttributedString()
auto reactTreeAttributedString = getAttributedString();
// Sometimes the treeAttributedString will only differ from the state
// not by inherent properties (string or prop attributes), but by the frame of
// the parent which has changed Thus, we can't directly compare the entire
// AttributedString
bool treeAttributedStringChanged =
!state.reactTreeAttributedString.compareTextAttributesWithoutFrame(
reactTreeAttributedString);
return (
state.reactTreeAttributedString == reactTreeAttributedString
? state.attributedString
: reactTreeAttributedString);
!treeAttributedStringChanged ? state.attributedString
: reactTreeAttributedString);
}
void AndroidTextInputShadowNode::updateStateIfNeeded() {