Skip to content

Commit 8f83ec6

Browse files
protikbiswas100Protik Biswas
andauthored
adding typescript support for accessibilityTap prop that was missing (#14938)
* adding typescript support for accessibilityValue prop that was missing * added button.d.ts and tester changes * yarn Change * Updated snapshot * adding onPress event on accessibilityTap prop --------- Co-authored-by: Protik Biswas <[email protected]> Co-authored-by: Protik Biswas <[email protected]>
1 parent 21f3d40 commit 8f83ec6

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "adding typescript support for onAccessibilitytap for button that was missing",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "none"
7+
}

packages/@react-native-windows/tester/src/js/examples-win/Button/ButtonExample.windows.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ exports.examples = [
8282
color={theme.SystemRedColor}
8383
title="Cancel"
8484
accessibilityLabel="Press to cancel your application!"
85+
onAccessibilityTap={() => onButtonPress('cancelled')}
8586
/>
8687
<Button
8788
onPress={() => onButtonPress('submitted')}

packages/e2e-test-app-fabric/test/__snapshots__/snapshotPages.test.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8836,6 +8836,7 @@ exports[`snapshotAllPages Button 3`] = `
88368836
}
88378837
accessible={true}
88388838
focusable={true}
8839+
onAccessibilityTap={[Function]}
88398840
onBlur={[Function]}
88408841
onClick={[Function]}
88418842
onFocus={[Function]}

packages/playground/Samples/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,18 @@ class TicTacButton extends React.Component<{}, {text: string}> {
3939
title={this.state.text}
4040
accessibilityLabel={this.state.text}
4141
accessibilityValue={{text: this.state.text}}
42+
onAccessibilityTap={() => this._onPress()}
4243
/>
4344
);
4445
}
4546

46-
_onPress(_event: NativeSyntheticEvent<NativeTouchEvent>) {
47+
_onPress = (_event?: NativeSyntheticEvent<NativeTouchEvent>) => {
4748
if (this.state.text === 'X') {
4849
this.setState({text: 'o'});
4950
} else {
5051
this.setState({text: 'X'});
5152
}
52-
}
53+
};
5354
}
5455

5556
class PopupButton extends React.Component<

vnext/src-win/Libraries/Components/Button.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export interface ButtonProps
3838
* Color of the text (iOS), or background color of the button (Android).
3939
*/
4040
color?: ColorValue | undefined;
41+
42+
onAccessibilityTap?: () => void; // Windows
4143
}
4244

4345
export class Button extends React.Component<ButtonProps> {}

0 commit comments

Comments
 (0)