Skip to content

Commit 42031cf

Browse files
authored
Merge branch 'main' into perf-artifact-hidden-files
2 parents 0021924 + 6f1ea33 commit 42031cf

18 files changed

Lines changed: 564 additions & 6993 deletions

File tree

.github/workflows/move-issues-milestones.yml

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Add onAuxClick event",
4+
"packageName": "react-native-windows",
5+
"email": "30809111+acoates-ms@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Fix NativeModule templates to work with clang",
4+
"packageName": "react-native-windows",
5+
"email": "30809111+acoates-ms@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
4+
*
5+
* @flow strict-local
6+
* @format
7+
*/
8+
9+
'use strict';
10+
11+
import type {RNTesterModuleExample} from '../../types/RNTesterTypes';
12+
13+
const React = require('react');
14+
import {Pressable, StyleSheet, View} from 'react-native';
15+
import RNTesterText from '../../components/RNTesterText';
16+
17+
function PointerClickEventsExample(): React.Node {
18+
const [text, setText] = React.useState(
19+
'onClick should cause the box to go red, onAuxClick will cause it go green',
20+
);
21+
const [bgColor, setBgColor]= React.useState('gray');
22+
return (
23+
<View>
24+
<View
25+
accessible
26+
testID="pointer-click-target"
27+
style={[styles.targetBox, {backgroundColor: bgColor}]}
28+
onClick={(e) => {
29+
setBgColor('red');
30+
setText('onClick.nativeEvent: ' + JSON.stringify(e.nativeEvent, null, 2));
31+
}}
32+
onAuxClick={(e) => {
33+
setBgColor('green');
34+
setText('onAuxClick.nativeEvent: ' + JSON.stringify(e.nativeEvent, null, 2));
35+
}}
36+
/>
37+
<RNTesterText accessible testID='pointer-click-text'>{text}</RNTesterText>
38+
</View>
39+
40+
);
41+
}
42+
43+
exports.displayName = 'PointerClickExample';
44+
exports.framework = 'React';
45+
exports.category = 'Basic';
46+
exports.title = 'Pointer Clicks';
47+
exports.documentationURL =
48+
'https://developer.mozilla.org/en-US/docs/Web/API/Element/auxclick_event';
49+
exports.description =
50+
'Tests that onClick and onAuxClick work.';
51+
52+
exports.examples = [
53+
{
54+
title: 'onClick/onAuxClick test',
55+
description:
56+
'Click the box with different pointers/buttons to test pointer click events.',
57+
render: function (): React.Node {
58+
return <PointerClickEventsExample />;
59+
},
60+
},
61+
] as Array<RNTesterModuleExample>;
62+
63+
const styles = StyleSheet.create({
64+
targetBox: {
65+
width: 200,
66+
height: 200,
67+
margin: 10,
68+
borderRadius: 10,
69+
justifyContent: 'center',
70+
alignItems: 'center',
71+
},
72+
});

packages/@react-native-windows/tester/src/js/utils/RNTesterList.windows.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,11 @@ const APIs: Array<RNTesterModuleInfo> = ([
399399
category: 'Basic',
400400
module: require('../examples/PointerEvents/PointerEventsExample'),
401401
},
402+
{
403+
key: 'PointerClickEventsExample',
404+
category: 'Basic',
405+
module: require('../examples-win/Pointer/PointerClickEventsExample'),
406+
},
402407
{
403408
key: 'PointerButtonExample',
404409
category: 'Basic',

packages/e2e-test-app-fabric/test/HomeUIADump.test.ts

Lines changed: 0 additions & 85 deletions
This file was deleted.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/**
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
4+
*
5+
* @format
6+
*/
7+
8+
import { goToApiExample } from './RNTesterNavigation';
9+
import { verifyNoErrorLogs } from './Helpers';
10+
import { app } from '@react-native-windows/automation';
11+
12+
beforeAll(async () => {
13+
// If window is partially offscreen, tests will fail to click on certain elements
14+
await app.setWindowPosition(0, 0);
15+
await app.setWindowSize(1000, 1250);
16+
await goToApiExample('Pointer Clicks');
17+
});
18+
19+
afterEach(async () => {
20+
await verifyNoErrorLogs();
21+
});
22+
23+
24+
describe('Pointer onClick Test', () => {
25+
test('onClick reports correct native event properties on left click', async () => {
26+
const component = await app.findElementByTestID('pointer-click-target');
27+
await component.waitForDisplayed({ timeout: 5000 });
28+
29+
// Left click triggers onPointerDown with button=0
30+
await component.click();
31+
const stateText = await app.findElementByTestID('pointer-click-text');
32+
33+
await app.waitUntil(
34+
async () => {
35+
const currentText = await stateText.getText();
36+
return currentText.includes('"button": 0') && currentText.includes('onClick');
37+
},
38+
{
39+
timeout: 5000,
40+
timeoutMsg:
41+
'State text not updated after onClick with button property.',
42+
},
43+
);
44+
45+
const text = await stateText.getText();
46+
expect(text).toMatchSnapshot();
47+
});
48+
test('onAuxClick reports correct native event properties on middle click', async () => {
49+
const component = await app.findElementByTestID('pointer-click-target');
50+
await component.waitForDisplayed({ timeout: 5000 });
51+
52+
// Middle click triggers onPointerDown with button=1
53+
await component.click({ button: 'middle' });
54+
const stateText = await app.findElementByTestID('pointer-click-text');
55+
56+
await app.waitUntil(
57+
async () => {
58+
const currentText = await stateText.getText();
59+
return currentText.includes('"button": 1') && currentText.includes('onAuxClick');
60+
},
61+
{
62+
timeout: 5000,
63+
timeoutMsg:
64+
'State text not updated after onAuxClick with middle button property.',
65+
},
66+
);
67+
68+
const text = await stateText.getText();
69+
expect(text).toMatchSnapshot();
70+
});
71+
test('onAuxClick reports correct native event properties on right click', async () => {
72+
const component = await app.findElementByTestID('pointer-click-target');
73+
await component.waitForDisplayed({ timeout: 5000 });
74+
75+
// Middle click triggers onPointerDown with button=2
76+
await component.click({ button: 'right' });
77+
const stateText = await app.findElementByTestID('pointer-click-text');
78+
79+
await app.waitUntil(
80+
async () => {
81+
const currentText = await stateText.getText();
82+
return currentText.includes('"button": 2') && currentText.includes('onAuxClick');
83+
},
84+
{
85+
timeout: 5000,
86+
timeoutMsg:
87+
'State text not updated after onAuxClick with right button property.',
88+
},
89+
);
90+
91+
const text = await stateText.getText();
92+
expect(text).toMatchSnapshot();
93+
});
94+
95+
});

0 commit comments

Comments
 (0)