From bcf0353873bb15019544833e6733cabe7b1b93b6 Mon Sep 17 00:00:00 2001 From: vineethkuttan Date: Wed, 27 Aug 2025 11:52:23 +0530 Subject: [PATCH 1/3] Few more implementation of TextRange Provider --- .../CompositionTextRangeProvider.cpp | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionTextRangeProvider.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionTextRangeProvider.cpp index 1f69c84b3df..d2d3f43cf36 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionTextRangeProvider.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionTextRangeProvider.cpp @@ -18,14 +18,29 @@ CompositionTextRangeProvider::CompositionTextRangeProvider( } HRESULT __stdcall CompositionTextRangeProvider::Clone(ITextRangeProvider **pRetVal) { - // no-op - *pRetVal = nullptr; + if (pRetVal == nullptr) + return E_POINTER; + + auto clone = winrt::make(m_view.view().as(), m_parentProvider.get()); + *pRetVal = clone.detach(); return S_OK; } HRESULT __stdcall CompositionTextRangeProvider::Compare(ITextRangeProvider *range, BOOL *pRetVal) { - // no-op - *pRetVal = false; + if (pRetVal == nullptr) + return E_POINTER; + if (range == nullptr) { + *pRetVal = FALSE; + return S_OK; + } + + // Try to cast to our type , considering provider only supports a single range per view + auto other = dynamic_cast(range); + if (other && other->m_view.view() == m_view.view()) { + *pRetVal = TRUE; + } else { + *pRetVal = FALSE; + } return S_OK; } @@ -34,7 +49,10 @@ HRESULT __stdcall CompositionTextRangeProvider::CompareEndpoints( ITextRangeProvider *targetRange, TextPatternRangeEndpoint targetEndpoint, int *pRetVal) { - // no-op + if (pRetVal == nullptr) + return E_POINTER; + + // For a single-range provider, always equal: *pRetVal = 0; return S_OK; } @@ -98,13 +116,13 @@ HRESULT __stdcall CompositionTextRangeProvider::GetAttributeValue(TEXTATTRIBUTEI textTransform = props->textAttributes.textTransform.value(); } if (fontVariant == facebook::react::FontVariant::SmallCaps) { - return CapStyle_SmallCap; + pRetVal->lVal = CapStyle_SmallCap; } else if (textTransform == facebook::react::TextTransform::Capitalize) { - return CapStyle_Titling; + pRetVal->lVal = CapStyle_Titling; } else if (textTransform == facebook::react::TextTransform::Lowercase) { - return CapStyle_None; + pRetVal->lVal = CapStyle_None; } else if (textTransform == facebook::react::TextTransform::Uppercase) { - return CapStyle_AllCap; + pRetVal->lVal = CapStyle_AllCap; } } else if (attributeId == UIA_FontNameAttributeId) { pRetVal->vt = VT_BSTR; @@ -282,6 +300,8 @@ HRESULT __stdcall CompositionTextRangeProvider::ScrollIntoView(BOOL alignToTop) return S_OK; } +// All the below methods should be implemented once the selection comes for paragraph and TextInput + HRESULT __stdcall CompositionTextRangeProvider::AddToSelection() { // no-op return S_OK; From 095fe4944a28a5703c14f29c1b957d15aad2a3b5 Mon Sep 17 00:00:00 2001 From: vineethkuttan Date: Fri, 29 Aug 2025 11:07:57 +0530 Subject: [PATCH 2/3] Yarn change --- ...ative-windows-4046d3e2-cc00-459e-b62d-4489b3ef14d1.json | 7 +++++++ .../Fabric/Composition/CompositionTextRangeProvider.cpp | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 change/react-native-windows-4046d3e2-cc00-459e-b62d-4489b3ef14d1.json diff --git a/change/react-native-windows-4046d3e2-cc00-459e-b62d-4489b3ef14d1.json b/change/react-native-windows-4046d3e2-cc00-459e-b62d-4489b3ef14d1.json new file mode 100644 index 00000000000..c602d400a0f --- /dev/null +++ b/change/react-native-windows-4046d3e2-cc00-459e-b62d-4489b3ef14d1.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "[Fabric] Fix for TextInput focus issue with screen readers.", + "packageName": "react-native-windows", + "email": "kvineeth@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionTextRangeProvider.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionTextRangeProvider.cpp index d2d3f43cf36..e2260913e15 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionTextRangeProvider.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionTextRangeProvider.cpp @@ -21,7 +21,8 @@ HRESULT __stdcall CompositionTextRangeProvider::Clone(ITextRangeProvider **pRetV if (pRetVal == nullptr) return E_POINTER; - auto clone = winrt::make(m_view.view().as(), m_parentProvider.get()); + auto clone = winrt::make( + m_view.view().as(), m_parentProvider.get()); *pRetVal = clone.detach(); return S_OK; } From 6a154415b621693ed00a21381f911c0f5eedf567 Mon Sep 17 00:00:00 2001 From: vineethkuttan Date: Fri, 29 Aug 2025 11:52:07 +0530 Subject: [PATCH 3/3] Update Change file --- ...act-native-windows-4046d3e2-cc00-459e-b62d-4489b3ef14d1.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/change/react-native-windows-4046d3e2-cc00-459e-b62d-4489b3ef14d1.json b/change/react-native-windows-4046d3e2-cc00-459e-b62d-4489b3ef14d1.json index c602d400a0f..d16b5587b17 100644 --- a/change/react-native-windows-4046d3e2-cc00-459e-b62d-4489b3ef14d1.json +++ b/change/react-native-windows-4046d3e2-cc00-459e-b62d-4489b3ef14d1.json @@ -1,6 +1,6 @@ { "type": "prerelease", - "comment": "[Fabric] Fix for TextInput focus issue with screen readers.", + "comment": "[Fabric] Fix for Text and TextInput focus issue with screen readers.", "packageName": "react-native-windows", "email": "kvineeth@microsoft.com", "dependentChangeType": "patch"