Skip to content

Commit 22add58

Browse files
authored
Fix TextInput selection prop (#15672) (#15673)
* Fix TextInput selection crash and feedback loop * Change files * add comment for the drawblock defer added
1 parent 430ab4c commit 22add58

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Fix TextInput selection crash and feedback loop",
4+
"packageName": "react-native-windows",
5+
"email": "74712637+iamAbhi-916@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,8 +1227,11 @@ void WindowsTextInputComponentView::updateState(
12271227
if (m_mostRecentEventCount == m_state->getData().mostRecentEventCount) {
12281228
m_comingFromState = true;
12291229
auto &fragments = m_state->getData().attributedStringBox.getValue().getFragments();
1230-
UpdateText(fragments.size() ? fragments[0].string : "");
1231-
1230+
{
1231+
// DrawBlock defers DrawText() until after UpdateText completes
1232+
DrawBlock db(*this);
1233+
UpdateText(fragments.size() ? fragments[0].string : "");
1234+
}
12321235
m_comingFromState = false;
12331236
}
12341237
}
@@ -1377,7 +1380,7 @@ void WindowsTextInputComponentView::EmitOnScrollEvent() noexcept {
13771380
}
13781381

13791382
void WindowsTextInputComponentView::OnSelectionChanged(LONG start, LONG end) noexcept {
1380-
if (m_eventEmitter && !m_comingFromState /* && !m_comingFromJS ?? */) {
1383+
if (m_eventEmitter && !m_comingFromState && !m_comingFromJS) {
13811384
auto emitter = std::static_pointer_cast<const facebook::react::WindowsTextInputEventEmitter>(m_eventEmitter);
13821385
facebook::react::WindowsTextInputEventEmitter::OnSelectionChange onSelectionChangeArgs;
13831386
onSelectionChangeArgs.selection.start = start;

0 commit comments

Comments
 (0)