Skip to content

Commit 5404e93

Browse files
authored
Fix selection getting lost on Android on the new arch (#335)
1 parent 306d6f5 commit 5404e93

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

android/src/main/new_arch/MarkdownCommitHook.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ RootShadowNode::Unshared MarkdownCommitHook::shadowTreeWillCommit(
112112
// force measurement of a map buffer
113113
newStateData->cachedAttributedStringId = 0;
114114

115+
// setting -1 as the event counter makes sure that the update will be ignored by the java
116+
// part of the code, which is what we want as we don't change the attributed string here
117+
if (previousEventCount_.contains(nodes.textInput->getTag()) &&
118+
previousEventCount_[nodes.textInput->getTag()] == stateData.mostRecentEventCount) {
119+
newStateData->mostRecentEventCount = -1;
120+
} else {
121+
previousEventCount_[nodes.textInput->getTag()] = stateData.mostRecentEventCount;
122+
}
123+
115124
// clone the text input with the new state
116125
auto newNode = node.clone({
117126
.state =

android/src/main/new_arch/MarkdownCommitHook.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class MarkdownCommitHook : public UIManagerCommitHook {
4747
textLayoutManagers_;
4848
std::unordered_map<facebook::react::Tag, folly::dynamic>
4949
previousDecoratorProps_;
50+
std::unordered_map<facebook::react::Tag, int64_t>
51+
previousEventCount_;
5052
};
5153

5254
} // namespace livemarkdown

0 commit comments

Comments
 (0)