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

Replace newlines in a11y labels with spaces #502

Merged
merged 2 commits into from
Jun 17, 2024

Conversation

nsillik
Copy link
Contributor

@nsillik nsillik commented Jun 17, 2024

The built in accessibility labels do some mangling of newlines to remove them. Our implementation in 0e9041b4714cac99baa69f4b1b484503868311ba caused regressions in snapshot and KIF testing.

@nsillik nsillik requested a review from a team as a code owner June 17, 2024 16:19
return label

// We need to replace all newlines with \n
return label.components(separatedBy: .newlines).filter { !$0.isEmpty }.joined(separator: " ")
Copy link
Collaborator

@kyleve kyleve Jun 17, 2024

Choose a reason for hiding this comment

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

Unit tests please!

Copy link
Collaborator

Choose a reason for hiding this comment

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

To be explicit, theres no prohibition against new lines in accessibility labels. This is a style choice we've made.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the tests were a good idea! you'll never believe this: they caught a bug (the change up above that i missed)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we move the line into a private category on string in this file now that we have two copies?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

@RoyalPineapple RoyalPineapple self-requested a review June 17, 2024 16:28
@RoyalPineapple
Copy link
Collaborator

Thanks for fixing the regression.

The built in accessibility labels do some mangling of newlines to remove
them. Our implementation in `0e9041b4714cac99baa69f4b1b484503868311ba`
caused regressions in snapshot and KIF testing.
@nsillik nsillik force-pushed the nsillik/fix-a11y-newlines-2 branch from 0b25f8d to c801e91 Compare June 17, 2024 16:36
!links.isEmpty
else {
// We need to replace all newlines with " "
return string.components(separatedBy: .newlines).filter { !$0.isEmpty }.joined(separator: " ")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes me question where this was happening before...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably the default value coming from UIKit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, that's what i think too

Copy link
Collaborator

Choose a reason for hiding this comment

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

yea, i tested it and it seems to be happening inside UILabel and only occurs when you don't provide an explicit label.

@nsillik nsillik merged commit 7270474 into main Jun 17, 2024
3 of 5 checks passed
@nsillik nsillik deleted the nsillik/fix-a11y-newlines-2 branch June 17, 2024 18:10
maxg-square added a commit that referenced this pull request Nov 4, 2024
* tag '4.3.0':
  Prepare version 4.3.0 (#513)
  Add passThroughTouches to BlueprintView, PassthroughView (#511)
  Bump checkout and upload-artifacts (#512)
  Bump rexml from 3.2.8 to 3.3.6
  Unnest Box.CornerStyle (#508)
  Prepare 4.2.1 (#507)
  Make public the UIBezierPath helper using Box.CornerStyle
  Prepare 4.2.0 (#505)
  Label and AttributedLabel now support accessibilityValue (#504)
  Prepare 4.1.2 Release (#503)
  Replace newlines in a11y labels with spaces (#502)
  Fix string index out of bounds crash. (#501)
  bumping version to 4.1.0 (#499)
  AttributedLabel Link Accessibility (#459)
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.

4 participants