Skip to content

Commit

Permalink
fix(android): ListView tap handling after setting children as focusab…
Browse files Browse the repository at this point in the history
…le (#10522)
  • Loading branch information
CatchABus committed Apr 19, 2024
1 parent fc55717 commit 03268cc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
20 changes: 5 additions & 15 deletions packages/core/ui/core/view/index.android.ts
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
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
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

0 comments on commit 03268cc

Please sign in to comment.