Skip to content

Commit 91d4ef1

Browse files
authored
[LinkV1] Simplify code to find child string of LinkV1 when setting a11yLabel (#3859)
* Check if we find a string as a child before calling .toString() * Change files * Simplify code to find child string of LinkV1
1 parent 0d66c8a commit 91d4ef1

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Simplify code to find child string of LinkV1",
4+
"packageName": "@fluentui-react-native/link",
5+
"email": "krsiler@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

packages/components/Link/src/Link.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,9 @@ export const Link = compose<LinkType>({
4949
// Views in Text, we use that to handle interactions instead.
5050
const supportsInteractionOnText = Platform.OS !== 'macos';
5151

52-
// Find the first child that's a string and save it to set as the link's
52+
// Find the first child that's a string (if it exists) and save it to set as the link's
5353
// accessibilityLabel if one isn't defined.
54-
let linkA11yLabel = '';
55-
linkA11yLabel = React.Children.toArray(children)
56-
.find((child) => typeof child === 'string')
57-
.toString();
54+
const linkA11yLabel = React.Children.toArray(children).find((child) => typeof child === 'string');
5855

5956
return supportsA11yTextInText && supportsInteractionOnText && (inline || mergedProps.selectable) ? (
6057
<Slots.content {...mergedProps}>{children}</Slots.content>

0 commit comments

Comments
 (0)