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": "[Fabric] Fix for Text and TextInput focus issue with screen readers.",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,30 @@ CompositionTextRangeProvider::CompositionTextRangeProvider(
}

HRESULT __stdcall CompositionTextRangeProvider::Clone(ITextRangeProvider **pRetVal) {
// no-op
*pRetVal = nullptr;
if (pRetVal == nullptr)
return E_POINTER;

auto clone = winrt::make<winrt::Microsoft::ReactNative::implementation::CompositionTextRangeProvider>(
m_view.view().as<winrt::Microsoft::ReactNative::Composition::ComponentView>(), 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<CompositionTextRangeProvider *>(range);
if (other && other->m_view.view() == m_view.view()) {
*pRetVal = TRUE;
} else {
*pRetVal = FALSE;
}
return S_OK;
}

Expand All @@ -34,7 +50,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;
}
Expand Down Expand Up @@ -98,13 +117,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;
Expand Down Expand Up @@ -282,6 +301,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;
Expand Down