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

Implement UIAccessibilityContainer informal protocol and make error labels accessible #5

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

sharplet
Copy link
Contributor

@sharplet sharplet commented Jan 7, 2016

Here's a quick summary of the changes

  • MFTextField is now an accessibility container.
  • The first accessible element is the underlying text field itself. (It's documented in the UIAccessibilityContainer informal protocol that an accessibility container can't itself be accessible, so how is this achieved? I've created a proxy element that decorates MFTextField and just delegates all accessibility properties to it.)
  • The second accessibility element is the error label. It's dynamically added and removed whenever the error label itself appears on screen. In addition, when the error label appears, I'm posting a UIAccessibilityLayoutChangedNotification, with the error label as the argument, so the error label gains focus whenever it appears.

Let me know if you have any questions! Seems to work ok using the demo app on my device.

The demo app target wasn't configured to embed
MaterialTextField.framework into the app, so when running on device the
framework couldn't be loaded and the app would crash.
For now the accessibility behaviour of the text field is identical to
before. The text field is now a container, and its
accessibilityElements include a single proxy element that just reports
the accessibility properties of the text field itself.
From the `NSObject(UIAccessibilityContainer)` docs:

> Containers can implement this property instead of the dynamic methods
> to support the retrieval of the contained elements. The default value
> of this property is nil.

This doesn't seem to be entirely true. The behaviour observed was:

- When navigating through MFTextFields, you could never sequentially
  navigate to the error label.
- You could find the error by moving your finger around until it gained
  focus.
- Once you'd located the error label this way, sequential navigation
  between accessibility elements was broken completely.

Adding implementations of the dynamic methods resolved the issue.
@stephsharp
Copy link
Owner

Found the following issues with voice over:

  • Cannot swipe up/down to move insertion point when editing text field
  • Cannot tap clear text button (black rectangle does not include the clear button like it does for UITextField)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants