-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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: Remove leading space from accessibilityLabel #12269
Conversation
In some cases, the accessibilityLabel contains a leading space. This is because `RCTRecursiveAccessibilityLabel` adds a space before every iteration of the loop including the first. After this change, the contract is that: - `RCTRecursiveAccessibilityLabel` always returns a string with a leading space. - `accessibilityLabel` never returns a string with a leading space. **Test plan** I created a test app with the following code: ``` <View style={{height: 100, width: 100, backgroundColor: 'steelblue'}} accessible={true}> <View style={{height: 20, width: 20, backgroundColor: 'red'}} accessibilityLabel='One' /> <View style={{height: 20, width: 20, backgroundColor: 'yellow'}} accessibilityLabel='Two' /> <View style={{height: 20, width: 20, backgroundColor: 'green'}} accessibilityLabel='Three' /> </View> ``` Before this change, the accessibilityLabel of the outermost View was " One Two Three" (notice the leading space). After this change, it is "One Two Three" as desired.
43761d7
to
3c1c8cc
Compare
I believe, it would be better if we will fix it inside |
This reverts commit 3c1c8cc. Implementing a different solution.
In some cases, the accessibilityLabel contains a leading space. This is because `RCTRecursiveAccessibilityLabel` adds a space before every iteration of the loop including the first. This change fixes it by avoiding adding a space on the first iteration of the loop.
@shergin Thanks for the feedback. I pushed a commit which does the fix inside of |
@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification. |
Summary: In some cases, the accessibilityLabel contains a leading space. This is because `RCTRecursiveAccessibilityLabel` adds a space before every iteration of the loop including the first. After this change, the contract is that: - `RCTRecursiveAccessibilityLabel` always returns a string with a leading space. - `accessibilityLabel` never returns a string with a leading space. **Test plan** I created a test app with the following code: ``` <View style={{height: 100, width: 100, backgroundColor: 'steelblue'}} accessible={true}> <View style={{height: 20, width: 20, backgroundColor: 'red'}} accessibilityLabel='One' /> <View style={{height: 20, width: 20, backgroundColor: 'yellow'}} accessibilityLabel='Two' /> <View style={{height: 20, width: 20, backgroundColor: 'green'}} accessibilityLabel='Three' /> </View> ``` Before this change, the accessibilityLabel of the outermost View was " One Two Three" (notice the leading space). After this change, it is "One Two Three" as desired. Adam Closes facebook#12269 Reviewed By: javache Differential Revision: D4596761 Pulled By: shergin fbshipit-source-id: 7d5ff704e858d9f277d1547339a2831ffa90f592
Summary: In some cases, the accessibilityLabel contains a leading space. This is because `RCTRecursiveAccessibilityLabel` adds a space before every iteration of the loop including the first. After this change, the contract is that: - `RCTRecursiveAccessibilityLabel` always returns a string with a leading space. - `accessibilityLabel` never returns a string with a leading space. **Test plan** I created a test app with the following code: ``` <View style={{height: 100, width: 100, backgroundColor: 'steelblue'}} accessible={true}> <View style={{height: 20, width: 20, backgroundColor: 'red'}} accessibilityLabel='One' /> <View style={{height: 20, width: 20, backgroundColor: 'yellow'}} accessibilityLabel='Two' /> <View style={{height: 20, width: 20, backgroundColor: 'green'}} accessibilityLabel='Three' /> </View> ``` Before this change, the accessibilityLabel of the outermost View was " One Two Three" (notice the leading space). After this change, it is "One Two Three" as desired. Adam Closes facebook#12269 Reviewed By: javache Differential Revision: D4596761 Pulled By: shergin fbshipit-source-id: 7d5ff704e858d9f277d1547339a2831ffa90f592
Summary: In some cases, the accessibilityLabel contains a leading space. This is because `RCTRecursiveAccessibilityLabel` adds a space before every iteration of the loop including the first. After this change, the contract is that: - `RCTRecursiveAccessibilityLabel` always returns a string with a leading space. - `accessibilityLabel` never returns a string with a leading space. **Test plan** I created a test app with the following code: ``` <View style={{height: 100, width: 100, backgroundColor: 'steelblue'}} accessible={true}> <View style={{height: 20, width: 20, backgroundColor: 'red'}} accessibilityLabel='One' /> <View style={{height: 20, width: 20, backgroundColor: 'yellow'}} accessibilityLabel='Two' /> <View style={{height: 20, width: 20, backgroundColor: 'green'}} accessibilityLabel='Three' /> </View> ``` Before this change, the accessibilityLabel of the outermost View was " One Two Three" (notice the leading space). After this change, it is "One Two Three" as desired. Adam Closes facebook#12269 Reviewed By: javache Differential Revision: D4596761 Pulled By: shergin fbshipit-source-id: 7d5ff704e858d9f277d1547339a2831ffa90f592
I'm not sure if it's just my setup but I'm still getting whitespaces in my accessibility labels even after applying this patch. Probably due to higher-order components (e.g Redux's Here's a sample output that
Could it be that the some components return blank as |
@jaunesarmiento What version of React Native are you using? Are you sure it includes the fix? |
@rigdern 0.42. I've used the commit as a patch. Yes, the fix is included cause the prior to this fix, the following have leading whitespace in them:
|
@rigdern nevermind. Found out that it's easier to use |
@jaunesarmiento Obviously, you should not use |
@jaunesarmiento I know you may not be interested anymore but I suspect PR #14177 will fix your issue. |
In some cases, the accessibilityLabel contains a leading space. This is because
RCTRecursiveAccessibilityLabel
adds a space before every iteration of the loop including the first.This change fixes it by avoiding adding a space on the first iteration of the loop.
Test plan
I created a test app with the following code:
Before this change, the accessibilityLabel of the outermost View was " One Two Three" (notice the leading space).
After this change, it is "One Two Three" as desired.
Adam Comella
Microsoft Corp.