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

iOS: add accessibilityElements to Ti.UI.View to order VoiceOver labels #13973

Open
1 task done
m1ga opened this issue Jan 24, 2024 · 1 comment
Open
1 task done

iOS: add accessibilityElements to Ti.UI.View to order VoiceOver labels #13973

m1ga opened this issue Jan 24, 2024 · 1 comment
Labels
feature ios needs triage This issue hasn't been reviewed by maintainers

Comments

@m1ga
Copy link
Contributor

m1ga commented Jan 24, 2024

I have searched and made sure there are no existing issues for the issue I am filing

  • I have searched the existing issues

Description

Slack request for a11y improvements:

Currently the order of the VoiceOver can be in a different order on iOS.

Solution

use accessibilityElements with a list of views to specify the order.

Alternatives

Hyperloop example code

accessibilityView.textField.addEventListener('postlayout', applyAccessibilitySettings);
accessibilityView.icon.addEventListener('postlayout', applyAccessibilitySettings);
accessibilityView.button.addEventListener('postlayout', applyAccessibilitySettings);

function applyAccessibilitySettings(e){
        const UIView = require('UIKit/UIView');

        // Access the native views
        var nativeTextField = UIView.cast(accessibilityView.textField);
        var nativeIcon = UIView.cast(accessibilityView.icon);
        var nativeButton = UIView.cast(accessibilityView.button);

        if(nativeTextField && nativeIcon && nativeButton){
            var accessibilityElements = [nativeTextField, nativeIcon, nativeButton];

            var nativeSearchView = UIView.cast(accessibilityView.searchView);
            nativeSearchView.setAccessibilityElements(accessibilityElements);
        }
    }

Platforms

iOS

@m1ga m1ga added feature needs triage This issue hasn't been reviewed by maintainers labels Jan 24, 2024
@empiresdev
Copy link

I tried to use the the view.toImage().nativeView as the documentation says but only got undefined as a result. So the only solution that worked was casting the Titanium UI element with UIView.cast call. The postlayout event also waits for the UI element to be rendered.

It would be great if we could simply define the accessibilityElements attribute of a Ti.UI.View as an array of UI elements as we already do with other accessibility attributes (for example, accessibilityLabel).

@m1ga m1ga added the ios label Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ios needs triage This issue hasn't been reviewed by maintainers
Projects
None yet
Development

No branches or pull requests

2 participants