Skip to content
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

[BUG] Touchbehavior Keyboard Access Click not working on Android #2443

Open
2 tasks done
plewm opened this issue Jan 15, 2025 · 1 comment
Open
2 tasks done

[BUG] Touchbehavior Keyboard Access Click not working on Android #2443

plewm opened this issue Jan 15, 2025 · 1 comment
Labels
area/behaviors Issue/Discussion/PR that has to do with Behaviors bug Something isn't working unverified

Comments

@plewm
Copy link

plewm commented Jan 15, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

When you use an App on Android via Keyboard access/navigation and you try to hit a button via space bar for example, the animation is executed, but the click event is not raised or executed

Expected Behavior

You would expect the Click to be executed normally, like it does on iOS

Steps To Reproduce

  1. Just add the Touchbehavior to any component
  2. try using the App with Keyboard
  3. navigate to that component
  4. press space bar to initiate click

In the Example App:

  1. Navigate via Tab on keyboard to the Border with TouchBehavior
  2. Press Space bar to Click -> nothing happens
  3. Touch normally -> works
  4. activate TalkBack
  5. Navigate again by Tab on Keyboard
  6. Press Space bar -> works

Link to public reproduction project repository

https://github.com/plewm/TouchbehaviorExample

Environment

- .NET MAUI CommunityToolkit: 9.1.0
- OS: macOS 15.1 (24B83)
- .NET MAUI: 8.0.402.1

Anything else?

From my debugging I found the issue to be the accessibilityManager and bool IsAccessibilityMode. it seems the accessibilityManager is null and accessibility mode is just false if the App is only used with keyboard. It will only be set if TalkBack is activated on the device. The Keyboard actions than also work, when TalkBack is activated as well. But the App should be usable with only keyboard without TalkBack as well. The Problem is, that the bool IsAccessibilityMode is checked in the OnClick method and is not reaching the HandleTouchEnded if AccessibilityMode is false.:

`void UpdateClickHandler()
{
if (view is null || !view.IsAlive())
{
return;
}

	view.Click -= OnClick;
	if (IsAccessibilityMode || (IsEnabled && (Element?.IsEnabled ?? false)))
	{
		view.Click += OnClick;
		return;
	}
}

void OnClick(object? sender, EventArgs args)
{
if (!IsEnabled)
{
return;
}

	if (!IsAccessibilityMode)
	{
		return;
	}

	IsCanceled = false;
	HandleTouchEnded(TouchStatus.Completed);
}`

Furthermore that implementation feels not as Android intended cause the documentation on Android side says not to do different stuff based on the AccessibilityManger because it results in inconsistent behavior.

isEnabled
Added in API level 4
public boolean isEnabled ()
Returns if the accessibility in the system is enabled.
Note: This query is used for sending AccessibilityEvents, since events are only needed if accessibility is on. Avoid changing UI or app behavior based on the state of accessibility. While well-intentioned, doing this creates brittle, less well-maintained code that works for some users but not others. Shared code leads to more equitable experiences and less technical debt.

https://developer.android.com/reference/android/view/accessibility/AccessibilityManager

@plewm plewm added bug Something isn't working unverified labels Jan 15, 2025
@jfversluis jfversluis added the area/behaviors Issue/Discussion/PR that has to do with Behaviors label Jan 16, 2025
@jfversluis
Copy link
Member

I see you mention .NET MAUI on .NET 8, are you able to test with .NET 9? And the latest Toolkit release? Does that change anything? Just to make sure we're looking at the latest and greatest?

It does seem that you already dug in quite a bit. Maybe you're able to propose a change for this through a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/behaviors Issue/Discussion/PR that has to do with Behaviors bug Something isn't working unverified
Projects
None yet
Development

No branches or pull requests

2 participants