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

Apply Accessibility traits to controls that have TapGestureRecognizers #1886

Merged
merged 7 commits into from
Aug 2, 2021

Conversation

PureWeen
Copy link
Member

@PureWeen PureWeen commented Jul 30, 2021

Description of Change

If users attach a touch gesture recognizer that will activate with a single touch then we add accessibility traits that will inform readers that the element is clickable.

Move all the semantic processing logic to extension methods to allow users to reuse if they need to

Make the MauiAccessibilityDelegate public for reuse

Adds an AccessibilityDelegateCompatWrapper that wraps an already assigned AccessibilityDelegateCompat. This allows you to easily retain the behavior of the current delegate and then add on to it

Alternative PR to
#1861

Additions made

// Contains logic for adding accessibility info if you're using a touch gesture
public class ControlsAccessibilityDelegate : AccessibilityDelegateCompatWrapper
// Allows users to call our code as an extension if they want to reuse any of our logic
// from their own custom code
namespace Microsoft.Maui.Controls.Platform
{
	public static class SemanticExtensions
	{
		public static void UpdateSemanticNodeInfo(this View virtualView, AccessibilityNodeInfoCompat? info)
// This allows you to take the existing delegate and wrap it if you want to retain
// the behavior of the Accessibility Delegate that's already assigned to the control
// We use this inside controls if we want to add additional accessibility delegate behavior
namespace Microsoft.Maui
{
	public class AccessibilityDelegateCompatWrapper : AccessibilityDelegateCompat
	{
		public AccessibilityDelegateCompatWrapper(AccessibilityDelegateCompat? originalDelegate)
		{
			_originalDelegate = originalDelegate ?? BlankDelegate;
		}
// Made our delegate public if users want to reuse it
public class MauiAccessibilityDelegateCompat : AccessibilityDelegateCompatWrapper

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)
  • Targets a single property for a single control (or intertwined few properties)
  • Adds the property to the appropriate interface
  • Avoids any changes not essential to the handler property
  • Adds the mapping to the PropertyMapper in the handler
  • Adds the mapping method to the Android, iOS, and Standard aspects of the handler
  • Implements the actual property updates (usually in extension methods in the Platform section of Core)
  • Tags ported renderer methods with [PortHandler]
  • Adds an example of the property to the sample project (MainPage)
  • Adds the property to the stub class
  • Implements basic property tests in DeviceTests

Does this PR touch anything that might affect accessibility?

  • Does this PR introduce a new control? (If yes, add an example using SemanticProperties to the SemanticsPage)
  • APIs that modify focusability?
  • APIs that modify any text property on a control?
  • Does this PR modify view nesting or view arrangement in anyway?
  • Is there the smallest possibility that your PR will change accessibility?
  • I'm not sure, please help me

If any of the above checkboxes apply to your PR, then the PR will need to provide testing to demonstrate that accessibility still works.

@PureWeen PureWeen changed the base branch from main to release/6.0.1xx-preview7 July 31, 2021 16:52
@PureWeen PureWeen changed the title Node info alternate Apply Accessibility traits to controls that have TapGestureRecognizers Jul 31, 2021
@PureWeen PureWeen marked this pull request as ready for review July 31, 2021 17:24
@PureWeen PureWeen added this to the 6.0.100-preview.7 milestone Jul 31, 2021
@@ -14,5 +18,99 @@ public static void SetSemanticFocus(this IFrameworkElement element)

view.SendAccessibilityEvent(EventTypes.ViewFocused);
}

public static void UpdateSemanticNodeInfo(this View nativeView, IView virtualView, AccessibilityNodeInfoCompat? info)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Copy link
Member

@rachelkang rachelkang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@PureWeen PureWeen merged commit f6a6952 into release/6.0.1xx-preview7 Aug 2, 2021
@PureWeen PureWeen deleted the node_info_alternate branch August 2, 2021 20:14
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2023
@Eilon Eilon added the t/a11y Relates to accessibility label May 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
legacy-area-a11y Relates to accessibility t/a11y Relates to accessibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants