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

Allow users to specify an accessibility identifier for the field #13

Closed
wants to merge 1 commit into from

Conversation

leopic
Copy link

@leopic leopic commented Mar 22, 2023

While trying to write UI tests for a view using this package I realized there was no way to specify an identifier.

@lukeredpath
Copy link
Owner

@leopic thanks for the PR - out of interest, does attaching an identifier to the ResponsiveTextView using SwiftUI's accessibility APIs not work?

@leopic
Copy link
Author

leopic commented Mar 22, 2023

@lukeredpath it did not on my first attempt, let me try one more time before merging.

@lukeredpath
Copy link
Owner

@leopic actually, I think this might be better served using the existing configuration system, which would allow you to configure as many accessibility properties as you need, for example:

public extension ResponsiveTextField.Configuration {
  static func accessibile(identifier: String) {
    $0.accessibilityIdentifier = identifier
    // any other accessibility traits/properties set here
  }
}

And then pass this in when creating the text field:

...
configuration: .accessible(identifier: "foo")

Or if you're already using a configuration:

...
configuration: .combine(.someExisting, .accessible(identifier: "foo"))

@leopic
Copy link
Author

leopic commented Mar 22, 2023

@lukeredpath it did actually work, my bad!

No need for this PR at all, but I did like your approach better, to be honest 😅 .

Thanks anyway.

@leopic leopic closed this Mar 22, 2023
@leopic leopic deleted the add-a11y-identifier branch March 22, 2023 14:07
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.

None yet

2 participants