diff --git a/change/react-native-windows-21c97e41-4926-4bce-98ce-832b24378038.json b/change/react-native-windows-21c97e41-4926-4bce-98ce-832b24378038.json new file mode 100644 index 00000000000..5ebd0b118f6 --- /dev/null +++ b/change/react-native-windows-21c97e41-4926-4bce-98ce-832b24378038.json @@ -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" +} diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp index 7d181804e43..8d3672ef894 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp @@ -26,6 +26,7 @@ #include "guid/msoGuid.h" #include +#include // convert a BSTR to a std::string. std::string &BstrToStdString(const BSTR bstr, std::string &dst, int cp = CP_UTF8) { @@ -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 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++; @@ -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(); }