Skip to content

Commit 6916370

Browse files
authored
[Fabric] Implement aria-level, aria-posinset, aria-setsize in Switch (#14735)
* [Fabric] Implement aria-level, aria-posinset, aria-setsize in Switch * Change files
1 parent 48b3be2 commit 6916370

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "[Fabric] Implement aria-level, aria-posinset, aria-setsize in Switch",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/playground/Samples/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ class PopupButton extends React.Component<
8181
<Switch
8282
value={this.state.isLightDismissEnabled}
8383
onValueChange={value => this.setState({isLightDismissEnabled: value})}
84+
aria-level={1}
85+
aria-posinset={1}
86+
aria-setsize={30}
8487
/>
8588
<Button
8689
onPress={this._onPress}

vnext/src-win/Libraries/Components/Switch/Switch.windows.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,16 @@ const Switch: component(
176176
thumbColor,
177177
trackColor,
178178
value,
179+
'aria-level': ariaLevel, // Windows
180+
'aria-posinset': ariaPosinset, // Windows
181+
'aria-setsize': ariaSetsize, // Windows
179182
...restProps
180183
} = props;
181184
const trackColorForFalse = trackColor?.false;
182185
const trackColorForTrue = trackColor?.true;
186+
const _accessibilityLevel = ariaLevel ?? props.accessibilityLevel; // Windows
187+
const _accessibilityPosInSet = ariaPosinset ?? props.accessibilityPosInSet; // Windows
188+
const _accessibilitySetSize = ariaSetsize ?? props.accessibilitySetSize; // Windows
183189

184190
const nativeSwitchRef = React.useRef<React.ElementRef<
185191
typeof SwitchNativeComponent | typeof AndroidSwitchNativeComponent,
@@ -278,6 +284,9 @@ const Switch: component(
278284
focusable={focusable === undefined ? true : focusable} // [Windows]
279285
accessible={accessible === undefined ? true : accessible} // [Windows]
280286
accessibilityRole={props.accessibilityRole ?? 'switch'}
287+
accessibilityLevel={_accessibilityLevel} // [Windows]
288+
accessibilityPosInSet={_accessibilityPosInSet} // [Windows]
289+
accessibilitySetSize={_accessibilitySetSize} // [Windows]
281290
onChange={handleChange}
282291
onResponderTerminationRequest={returnsFalse}
283292
onStartShouldSetResponder={returnsTrue}

0 commit comments

Comments
 (0)