Skip to content
Draft
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": "patch",
"comment": "Add runtime warning for unsupported keyboardType prop on Fabric TextInput",
"packageName": "react-native-windows",
"email": "nitchaudhary@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "guid/msoGuid.h"

#include <unicode.h>
#include <unordered_set>

// convert a BSTR to a std::string.
std::string &BstrToStdString(const BSTR bstr, std::string &dst, int cp = CP_UTF8) {
Expand Down Expand Up @@ -61,6 +62,19 @@ MSO_CLASS_GUID(ITextServices2, "8D33F741-CF58-11CE-A89D-00AA006CADC5") // IID_IT

namespace winrt::Microsoft::ReactNative::Composition::implementation {

namespace {
// Track which prop warnings have been emitted to avoid spamming the developer
static std::unordered_set<std::string> s_emittedPropWarnings;

// Emit a warning once per unique message
void EmitPropWarningOnce(const std::string &warningKey, const std::string &message) {
if (s_emittedPropWarnings.find(warningKey) == s_emittedPropWarnings.end()) {
s_emittedPropWarnings.insert(warningKey);
OutputDebugStringA(("[React Native Windows] " + message + "\n").c_str());
}
}
} // namespace

// RichEdit doesn't handle us calling Draw during the middle of a TxTranslateMessage call.
WindowsTextInputComponentView::DrawBlock::DrawBlock(WindowsTextInputComponentView &view) : m_view(view) {
m_view.m_cDrawBlock++;
Expand Down Expand Up @@ -1198,6 +1212,18 @@ void WindowsTextInputComponentView::updateProps(
m_needsRedraw = true;
}

// Warn about props that are not yet implemented on Windows
if (!newTextInputProps.keyboardType.empty() && newTextInputProps.keyboardType != "default") {
EmitPropWarningOnce(
"TextInput.keyboardType",
"The keyboardType prop for TextInput is not yet available on React Native Windows Fabric. "
"See: https://microsoft.github.io/react-native-windows/docs/new-arch-missingProps . "
"Setting keyboardType=\"" +
newTextInputProps.keyboardType +
"\" will not change the Touch Keyboard layout. "
"Currently supported value: 'default'");
}

UpdatePropertyBits();
}

Expand Down
Loading