8000 fix: Consider `isUserInteractionEnabled` value when setting accessibi… · NativeScript/NativeScript@6e10d9b · GitHub
[go: up one dir, main page]

Skip to content

Commit 6e10d9b

Browse files
committed
fix: Consider isUserInteractionEnabled value when setting accessibility
1 parent 87a5a92 commit 6e10d9b

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

packages/core/ui/core/view-base/index.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -985,13 +985,6 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
985985
//
986986
}
987987

988-
/**
989-
* This is called after the initialization of properties/listeners of the native view.
990-
*/
991-
public afterInitNativeView(): void {
992-
//
993-
}
994-
995988
/**
996989
* Resets properties/listeners set to the native view.
997990
*/
@@ -1140,7 +1133,6 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
11401133
if (this.__nativeView) {
11411134
this._suspendedUpdates = undefined;
11421135
this.initNativeView();
1143-
this.afterInitNativeView();
11441136
this._resumeNativeUpdates(SuspendType.NativeView);
11451137
}
11461138
}

packages/core/ui/core/view/index.android.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ export class View extends ViewCommon {
325325

326326
public _dialogFragment: androidx.fragment.app.DialogFragment;
327327
public _manager: androidx.fragment.app.FragmentManager;
328-
private _isFocusableByDefault: boolean = false;
329328
private touchListenerIsSet: boolean;
330329
private touchListener: android.view.View.OnTouchListener;
331330
private layoutChangeListenerIsSet: boolean;
@@ -471,14 +470,6 @@ export class View extends ViewCommon {
471470
}
472471
}
473472

474-
public afterInitNativeView(): void {
475-
super.afterInitNativeView();
476-
477-
// Setting this during initNativeView would result in skipping the right focusable state on views
478-
// like ListView which becomes focusable in initNativeView scope
479-
this._isFocusableByDefault = this.nativeViewProtected.isFocusable();
480-
}
481-
482473
public needsOnLayoutChangeListener() {
483474
return this.hasListeners(ViewCommon.layoutChangedEvent);
484475
}
@@ -833,14 +824,13 @@ export class View extends ViewCommon {
833824
}
834825

835826
[accessibilityEnabledProperty.setNative](value: boolean): void {
827+
// Even though this property can be true on initialization, views like layouts can be non-focusable
828+
const isUserInteractionEnabled = this.isUserInteractionEnabled && this.nativeViewProtected.isFocusable();
829+
830+
// ensure `accessibilityEnabled=false` does not disable focus for view with `isUserInteractionEnabled=true`
831+
this.nativeViewProtected.setFocusable(!!value || isUserInteractionEnabled);
836832
if (value) {
837-
this.nativeViewProtected.setFocusable(true);
838833
updateAccessibilityProperties(this);
839-
} else {
840-
// Mark as non-focusable only if view is supposed to be so by default
841-
if (!this._isFocusableByDefault) {
842-
this.nativeViewProtected.setFocusable(false);
843-
}
844834
}
845835
}
846836

0 commit comments

Comments
 (0)
0