revert: "perf: disable accessibility for layout views" (#10649)

This commit is contained in:
Dimitris-Rafail Katsampas
2024-11-19 05:49:44 +02:00
committed by GitHub
parent 4e54c676a3
commit 712a9f4848
6 changed files with 10 additions and 22 deletions

View File

@ -26,7 +26,6 @@ function makePropertyEnumConverter<T>(enumValues) {
export const accessibilityEnabledProperty = new CssProperty<Style, boolean>({ export const accessibilityEnabledProperty = new CssProperty<Style, boolean>({
name: 'accessible', name: 'accessible',
defaultValue: true,
cssName: 'a11y-enabled', cssName: 'a11y-enabled',
valueConverter: booleanConverter, valueConverter: booleanConverter,
}); });

View File

@ -832,10 +832,8 @@ export class View extends ViewCommon {
[accessibilityEnabledProperty.setNative](value: boolean): void { [accessibilityEnabledProperty.setNative](value: boolean): void {
this.nativeViewProtected.setFocusable(!!value); this.nativeViewProtected.setFocusable(!!value);
if (value) {
updateAccessibilityProperties(this); updateAccessibilityProperties(this);
} }
}
[accessibilityIdentifierProperty.setNative](value: string): void { [accessibilityIdentifierProperty.setNative](value: string): void {
this.setAccessibilityIdentifier(this.nativeViewProtected, value); this.setAccessibilityIdentifier(this.nativeViewProtected, value);

View File

@ -228,6 +228,11 @@ export abstract class View extends ViewCommon {
*/ */
color: Color; color: Color;
/**
* If `true` the element is an accessibility element and all the children will be treated as a single selectable component.
*/
accessible: boolean;
/** /**
* Hide the view and its children from the a11y service * Hide the view and its children from the a11y service
*/ */

View File

@ -683,10 +683,9 @@ export class View extends ViewCommon implements ViewDefinition {
[accessibilityEnabledProperty.setNative](value: boolean): void { [accessibilityEnabledProperty.setNative](value: boolean): void {
this.nativeViewProtected.isAccessibilityElement = !!value; this.nativeViewProtected.isAccessibilityElement = !!value;
if (value) {
updateAccessibilityProperties(this); updateAccessibilityProperties(this);
} }
}
[accessibilityIdentifierProperty.getDefault](): string { [accessibilityIdentifierProperty.getDefault](): string {
return this.nativeViewProtected.accessibilityIdentifier; return this.nativeViewProtected.accessibilityIdentifier;

View File

@ -194,10 +194,9 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
} }
} }
super.onLoaded(); super.onLoaded();
if (this.accessible) {
setupAccessibleView(this); setupAccessibleView(this);
} }
}
public _closeAllModalViewsInternal(): boolean { public _closeAllModalViewsInternal(): boolean {
if (_rootModalViews && _rootModalViews.length > 0) { if (_rootModalViews && _rootModalViews.length > 0) {

View File

@ -3,22 +3,10 @@ import { CoreTypes } from '../../core-types';
import { View, CustomLayoutView, AddChildFromBuilder } from '../core/view'; import { View, CustomLayoutView, AddChildFromBuilder } from '../core/view';
import { booleanConverter, getViewById } from '../core/view-base'; import { booleanConverter, getViewById } from '../core/view-base';
import { Property } from '../core/properties'; import { Property } from '../core/properties';
import { accessibilityEnabledProperty } from '../../accessibility/accessibility-properties';
export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefinition, AddChildFromBuilder { export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefinition, AddChildFromBuilder {
private _subViews = new Array<View>(); private _subViews = new Array<View>();
constructor() {
super();
/**
* mark accessible as false without triggering property change
* equivalent to changing the default
* TODO: Remove this when we have a more flexible API for declaring default property values per type of view
*/
this.style[accessibilityEnabledProperty.key] = false;
}
public _addChildFromBuilder(name: string, value: any) { public _addChildFromBuilder(name: string, value: any) {
if (value instanceof View) { if (value instanceof View) {
this.addChild(value); this.addChild(value);