Skip to content

fix(android): ListView tap not working after setting children as focusable #10522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 19, 2024
20 changes: 5 additions & 15 deletions packages/core/ui/core/view/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ function initializeDialogFragment() {
}
public onCreate(savedInstanceState: android.os.Bundle) {
super.onCreate(savedInstanceState);
var ownerId = this.getArguments()?.getInt(DOMID);
var options = getModalOptions(ownerId);
const ownerId = this.getArguments()?.getInt(DOMID);
const options = getModalOptions(ownerId);
// The teardown when the activity is destroyed happens after the state is saved, but is not recoverable,
// Cancel the native dialog in this case or the app will crash with subsequent errors.
if (savedInstanceState != null && options === undefined) {
Expand Down Expand Up @@ -325,7 +325,6 @@ export class View extends ViewCommon {

public _dialogFragment: androidx.fragment.app.DialogFragment;
public _manager: androidx.fragment.app.FragmentManager;
private _isClickable: boolean;
private touchListenerIsSet: boolean;
private touchListener: android.view.View.OnTouchListener;
private layoutChangeListenerIsSet: boolean;
Expand Down Expand Up @@ -465,7 +464,7 @@ export class View extends ViewCommon {

public initNativeView(): void {
super.initNativeView();
this._isClickable = this.nativeViewProtected.isClickable();

if (this.needsOnLayoutChangeListener()) {
this.setOnLayoutChangeListener();
}
Expand Down Expand Up @@ -825,8 +824,8 @@ export class View extends ViewCommon {
}

[accessibilityEnabledProperty.setNative](value: boolean): void {
// ensure `accessibilityEnabled=false` does not disable focus for view with `isUserInteractionEnabled=true`
this.nativeViewProtected.setFocusable(!!value || this.isUserInteractionEnabled);
this.nativeViewProtected.setFocusable(!!value);

if (value) {
updateAccessibilityProperties(this);
}
Expand Down Expand Up @@ -1265,15 +1264,6 @@ export class View extends ViewCommon {

export class ContainerView extends View {
public iosOverflowSafeArea: boolean;

constructor() {
super();
/**
* mark accessible as false without triggering proerty change
* equivalent to changing the default
*/
this.style[accessibilityEnabledProperty.key] = false;
}
}

export class CustomLayoutView extends ContainerView implements CustomLayoutViewDefinition {
Expand Down
5 changes: 0 additions & 5 deletions packages/core/ui/core/view/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1069,11 +1069,6 @@ export class ContainerView extends View {
constructor() {
super();
this.iosOverflowSafeArea = true;
/**
* mark accessible as false without triggering proerty change
* equivalent to changing the default
*/
this.style[accessibilityEnabledProperty.key] = false;
}
}

Expand Down
12 changes: 12 additions & 0 deletions packages/core/ui/layouts/layout-base-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@ import { CoreTypes } from '../../core-types';
import { View, CustomLayoutView, AddChildFromBuilder } from '../core/view';
import { booleanConverter, getViewById } from '../core/view-base';
import { Property } from '../core/properties';
import { accessibilityEnabledProperty } from '../../accessibility/accessibility-properties';

export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefinition, AddChildFromBuilder {
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) {
if (value instanceof View) {
this.addChild(value);
Expand Down
Loading