From 7884c98cc277755a5ebdd02a772ab04687402864 Mon Sep 17 00:00:00 2001 From: Nitin Chaudhary Date: Mon, 16 Mar 2026 08:34:38 +0530 Subject: [PATCH 1/2] feat(TextInput): Add runtime warning for unsupported keyboardType prop on Fabric --- .../WindowsTextInputComponentView.cpp | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp index 7d181804e43..b293453c078 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(); } @@ -1890,9 +1916,10 @@ void WindowsTextInputComponentView::OnContextMenuKey( if (!windowsTextInputProps().contextMenuHidden) { // m_caretPosition is stored from TxSetCaretPos in RichEdit client rect space (physical pixels). // LocalToScreen expects logical (DIP) coordinates, so divide by pointScaleFactor. - auto screenPt = LocalToScreen(winrt::Windows::Foundation::Point{ - static_cast(m_caretPosition.x) / m_layoutMetrics.pointScaleFactor, - static_cast(m_caretPosition.y) / m_layoutMetrics.pointScaleFactor}); + auto screenPt = LocalToScreen( + winrt::Windows::Foundation::Point{ + static_cast(m_caretPosition.x) / m_layoutMetrics.pointScaleFactor, + static_cast(m_caretPosition.y) / m_layoutMetrics.pointScaleFactor}); ShowContextMenu(screenPt); args.Handled(true); } From 57ee42b99fb72eae746d79667fa1a8590dc2c3fb Mon Sep 17 00:00:00 2001 From: Nitin Chaudhary Date: Mon, 16 Mar 2026 08:37:14 +0530 Subject: [PATCH 2/2] Change files --- ...ive-windows-21c97e41-4926-4bce-98ce-832b24378038.json | 7 +++++++ .../TextInput/WindowsTextInputComponentView.cpp | 9 ++++----- 2 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 change/react-native-windows-21c97e41-4926-4bce-98ce-832b24378038.json 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 b293453c078..8d3672ef894 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp @@ -1217,7 +1217,7 @@ void WindowsTextInputComponentView::updateProps( 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 " + "See: https://microsoft.github.io/react-native-windows/docs/new-arch-missingProps . " "Setting keyboardType=\"" + newTextInputProps.keyboardType + "\" will not change the Touch Keyboard layout. " @@ -1916,10 +1916,9 @@ void WindowsTextInputComponentView::OnContextMenuKey( if (!windowsTextInputProps().contextMenuHidden) { // m_caretPosition is stored from TxSetCaretPos in RichEdit client rect space (physical pixels). // LocalToScreen expects logical (DIP) coordinates, so divide by pointScaleFactor. - auto screenPt = LocalToScreen( - winrt::Windows::Foundation::Point{ - static_cast(m_caretPosition.x) / m_layoutMetrics.pointScaleFactor, - static_cast(m_caretPosition.y) / m_layoutMetrics.pointScaleFactor}); + auto screenPt = LocalToScreen(winrt::Windows::Foundation::Point{ + static_cast(m_caretPosition.x) / m_layoutMetrics.pointScaleFactor, + static_cast(m_caretPosition.y) / m_layoutMetrics.pointScaleFactor}); ShowContextMenu(screenPt); args.Handled(true); }