Skip to content

Defer the initialization of accessibility providers #14644

@vineethkuttan

Description

@vineethkuttan

if (strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::WindowsTextInputComponentView>() ||
strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::ParagraphComponentView>()) {
m_textProvider = winrt::make<CompositionTextProvider>(
strongView.as<winrt::Microsoft::ReactNative::Composition::ComponentView>(), this)
.try_as<ITextProvider2>();
}
if (strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::ViewComponentView>()) {
m_annotationProvider = winrt::make<CompositionAnnotationProvider>(
strongView.as<winrt::Microsoft::ReactNative::Composition::ComponentView>(), this)
.try_as<IAnnotationProvider>();

If the UIA agent does not request these patterns we shouldn't create these providers. But we are trying to create these providers in the constructor itself.

Changes required:

Move the above part of code to here, where we can create the providers, only if the UIA request for it.

if (patternId == UIA_TextPatternId &&
(strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::WindowsTextInputComponentView>() ||
strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::ParagraphComponentView>())) {
m_textProvider.as<IUnknown>().copy_to(pRetVal);
}
if (patternId == UIA_TextPattern2Id &&
strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::WindowsTextInputComponentView>()) {
m_textProvider.as<IUnknown>().copy_to(pRetVal);
}
if (patternId == UIA_AnnotationPatternId &&
strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::ViewComponentView>() &&
accessibilityAnnotationHasValue(props->accessibilityAnnotation)) {
m_annotationProvider.as<IUnknown>().copy_to(pRetVal);

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions