Skip to content

Commit f988b95

Browse files
hsourcepetertravelchime
authored andcommitted
Fixed ExampleBox in test case, added more new example
1 parent 4de4ad6 commit f988b95

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

packages/rn-tester/js/examples/PointerEvents/PointerEventsExample.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,30 @@ class ExampleBox extends React.Component<ExampleBoxProps, ExampleBoxState> {
3232
};
3333

3434
handleLog = (msg: string) => {
35-
this.setState({log: this.state.log.concat([msg])});
35+
// $FlowFixMe
36+
this.state.log = this.state.log.concat([msg]);
37+
};
38+
39+
flushReactChanges = () => {
40+
this.forceUpdate();
3641
};
3742

3843
/**
3944
* Capture phase of bubbling to append separator before any of the bubbling
4045
* happens.
4146
*/
4247
handleTouchCapture = () => {
43-
this.setState({log: this.state.log.concat(['---'])});
48+
// $FlowFixMe
49+
this.state.log = this.state.log.concat(['---']);
4450
};
4551

4652
render() {
4753
const {Component} = this.props;
4854
return (
4955
<View>
50-
<View onTouchEndCapture={this.handleTouchCapture}>
56+
<View
57+
onTouchEndCapture={this.handleTouchCapture}
58+
onTouchStart={this.flushReactChanges}>
5159
<Component onLog={this.handleLog} />
5260
</View>
5361
<View style={styles.logBox}>
@@ -195,6 +203,13 @@ class OverflowExample extends React.Component<OverflowExampleProps> {
195203
onTouchStart={() => this.props.onLog('C fully outside touched')}
196204
style={[styles.box, styles.boxFullyOutside]}>
197205
<DemoText style={styles.text}>C: fully outside</DemoText>
206+
<View
207+
onTouchStart={() =>
208+
this.props.onLog('D fully outside child touched')
209+
}
210+
style={[styles.box, styles.boxFullyOutsideChild]}>
211+
<DemoText style={styles.text}>D: child of fully outside</DemoText>
212+
</View>
198213
</View>
199214
</View>
200215
);
@@ -243,13 +258,13 @@ const exampleClasses: Array<ExampleClass> = [
243258
Component: OverflowVisibleExample,
244259
title: '`overflow: visible`',
245260
description:
246-
'`overflow: visible` style should allow subelements that are outside of the parent box to be touchable. Tapping the parts of Box B outside Box A should print "B touched" and "A touched", and tapping Box C should also print "C touched" and "A touched.',
261+
'`overflow: visible` style should allow subelements that are outside of the parent box to be touchable. Tapping the parts of Box B outside Box A should print "B touched" and "A touched", and tapping Box C should also print "C touched" and "A touched".',
247262
},
248263
{
249264
Component: OverflowHiddenExample,
250265
title: '`overflow: hidden`',
251266
description:
252-
"`overflow: hidden` style should only allow subelements within the parent box to be touchable. Tapping just below Box A (where Box B would otherwise extend if it weren't cut off) should not trigger any touches or messages.",
267+
'`overflow: hidden` style should only allow subelements within the parent box to be touchable. Tapping just below Box A (where Box B would otherwise extend if it weren\'t cut off) should not trigger any touches or messages. Touching Box D (inside the bounds) should print "D touched" and "A touched".',
253268
},
254269
];
255270

@@ -295,6 +310,12 @@ const styles = StyleSheet.create({
295310
left: 200,
296311
top: 65,
297312
},
313+
boxFullyOutsideChild: {
314+
position: 'absolute',
315+
left: 0,
316+
top: -65,
317+
width: 100,
318+
},
298319
logText: {
299320
fontSize: 9,
300321
},

0 commit comments

Comments
 (0)