Skip to content

Commit 0f2ce73

Browse files
author
farfromrefug
committed
fix(textview, textfield, android): accessibility fix
1 parent b5bf622 commit 0f2ce73

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

src/textfield/textfield.android.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import {
3333
profile,
3434
textAlignmentProperty
3535
} from '@nativescript/core';
36+
import { accessibilityIdentifierProperty } from '@nativescript/core/accessibility/accessibility-properties';
37+
import { testIDProperty } from '@nativescript/core/ui/core/view/view-common';
3638
import { secureProperty } from '@nativescript/core/ui/text-field';
3739
import { TextFieldBase } from './textfield.common';
3840

@@ -331,5 +333,13 @@ export class TextField extends TextFieldBase {
331333
const nativeView = this.nativeTextViewProtected;
332334
nativeView.setFocusable(value);
333335
}
336+
337+
[testIDProperty.setNative](value: string): void {
338+
this.setAccessibilityIdentifier(this.nativeTextViewProtected, value);
339+
}
340+
341+
[accessibilityIdentifierProperty.setNative](value: string): void {
342+
this.setAccessibilityIdentifier(this.nativeTextViewProtected, value);
343+
}
334344
}
335-
//
345+

src/textview/textview.android.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { VerticalTextAlignment, verticalTextAlignmentProperty } from '@nativescript-community/text';
22
import { themer } from '@nativescript-community/ui-material-core';
3-
import { getColorStateList, getFullColorStateList, getHorizontalGravity, getLayout, getVerticalGravity, inflateLayout } from '@nativescript-community/ui-material-core/android/utils';
3+
import { getColorStateList, getFullColorStateList, getHorizontalGravity, getVerticalGravity, inflateLayout } from '@nativescript-community/ui-material-core/android/utils';
44
import {
55
counterMaxLengthProperty,
66
errorColorProperty,
@@ -19,21 +19,19 @@ import {
1919
Color,
2020
CoreTypes,
2121
Font,
22-
Length,
2322
Utils,
2423
backgroundInternalProperty,
2524
borderBottomLeftRadiusProperty,
2625
fontInternalProperty,
2726
hintProperty,
28-
paddingBottomProperty,
29-
paddingLeftProperty,
30-
paddingRightProperty,
31-
paddingTopProperty,
3227
placeholderColorProperty,
3328
textAlignmentProperty
3429
} from '@nativescript/core';
3530
import { TextViewBase } from './textview.common';
3631

32+
import { accessibilityIdentifierProperty } from '@nativescript/core/accessibility/accessibility-properties';
33+
import { testIDProperty } from '@nativescript/core/ui/core/view/view-common';
34+
3735
let FrameLayoutLayoutParams: typeof android.widget.FrameLayout.LayoutParams;
3836
let filledId;
3937
let outlineId;
@@ -307,5 +305,12 @@ export class TextView extends TextViewBase {
307305
[verticalTextAlignmentProperty.setNative](value: VerticalTextAlignment) {
308306
this.nativeTextViewProtected.setGravity(getHorizontalGravity(this.textAlignment) | getVerticalGravity(value));
309307
}
308+
[testIDProperty.setNative](value: string): void {
309+
this.setAccessibilityIdentifier(this.nativeTextViewProtected, value);
310+
}
311+
312+
[accessibilityIdentifierProperty.setNative](value: string): void {
313+
this.setAccessibilityIdentifier(this.nativeTextViewProtected, value);
314+
}
310315
}
311-
//
316+

0 commit comments

Comments
 (0)