Skip to content
Merged
Show file tree
Hide file tree
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
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "If initial value is set, updated TextInput.value changes will not be reflected",
"packageName": "react-native-windows",
"email": "30809111+acoates-ms@users.noreply.github.com",
"dependentChangeType": "patch"
}
22 changes: 17 additions & 5 deletions vnext/Microsoft.ReactNative/Views/TextInputViewManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,16 @@ class TextInputShadowNode : public ShadowNodeBase {
void SetSelection(int64_t start, int64_t end);
winrt::Shape FindCaret(xaml::DependencyObject element);

bool m_initialUpdateComplete = false;
bool m_autoFocus = false;
bool m_shouldClearTextOnFocus = false;
bool m_shouldSelectTextOnFocus = false;
bool m_contextMenuHidden = false;
bool m_hideCaret = false;
bool m_isTextBox = true;
winrt::Microsoft::ReactNative::JSValue m_placeholderTextColor;
bool m_shouldClearTextOnSubmit = false;

winrt::Microsoft::ReactNative::JSValue m_placeholderTextColor;
std::vector<HandledKeyboardEvent> m_submitKeyEvents{};

// Javascripts is running in a different thread. If the typing is very fast,
Expand Down Expand Up @@ -175,6 +177,9 @@ void TextInputShadowNode::createView(const winrt::Microsoft::ReactNative::JSValu
}

void TextInputShadowNode::dispatchTextInputChangeEvent(winrt::hstring newText) {
if (!m_initialUpdateComplete) {
return;
}
m_nativeEventCount++;
folly::dynamic eventData = folly::dynamic::object("target", m_tag)("text", react::uwp::HstringToDynamic(newText))(
"eventCount", m_nativeEventCount);
Expand All @@ -199,14 +204,20 @@ void TextInputShadowNode::registerEvents() {
// another TextChanged event with correct event count.
if (m_isTextBox) {
m_passwordBoxPasswordChangingRevoker = {};
m_textBoxTextChangingRevoker = control.as<xaml::Controls::TextBox>().TextChanging(
winrt::auto_revoke, [=](auto &&, auto &&) { m_nativeEventCount++; });
m_textBoxTextChangingRevoker =
control.as<xaml::Controls::TextBox>().TextChanging(winrt::auto_revoke, [=](auto &&, auto &&) {
if (m_initialUpdateComplete)
m_nativeEventCount++;
});
} else {
m_textBoxTextChangingRevoker = {};

if (control.try_as<xaml::Controls::IPasswordBox4>()) {
m_passwordBoxPasswordChangingRevoker = control.as<xaml::Controls::IPasswordBox4>().PasswordChanging(
winrt::auto_revoke, [=](auto &&, auto &&) { m_nativeEventCount++; });
m_passwordBoxPasswordChangingRevoker =
control.as<xaml::Controls::IPasswordBox4>().PasswordChanging(winrt::auto_revoke, [=](auto &&, auto &&) {
if (m_initialUpdateComplete)
m_nativeEventCount++;
});
}
}

Expand Down Expand Up @@ -673,6 +684,7 @@ void TextInputShadowNode::updateProperties(winrt::Microsoft::ReactNative::JSValu
}

m_updating = false;
m_initialUpdateComplete = true;
}

void TextInputShadowNode::SetText(const winrt::Microsoft::ReactNative::JSValue &text) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,7 @@ function InternalTextInput(props: Props): React.Node {
ref={_setNativeRef}
{...props}
dataDetectorTypes={props.dataDetectorTypes}
mostRecentEventCount={mostRecentEventCount}
onBlur={_onBlur}
onChange={_onChange}
onContentSizeChange={props.onContentSizeChange}
Expand Down