Skip to content

Commit

Permalink
Modified RNTester Popup example to repro touch interaction problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Anderson committed Aug 25, 2020
1 parent bb6efc8 commit 93a31c0
Showing 1 changed file with 48 additions and 4 deletions.
52 changes: 48 additions & 4 deletions vnext/src/RNTester/js/examples-win/Popup/PopupExample.windows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@
*/

import React = require('react');
import {Button, Text, TextInput, View} from 'react-native';
import {
Button,
Text,
TextInput,
View,
TouchableHighlight,
ScrollView,
} from 'react-native';
import {Popup} from '../../../../Libraries/Components/Popup/Popup';

interface IAnchoredPopupExampleState {
showPopup: boolean;
buttonTitle: string;
touchCount: number;
}

class AnchoredPopupExample extends React.Component<
Expand All @@ -22,6 +30,7 @@ class AnchoredPopupExample extends React.Component<
public state: IAnchoredPopupExampleState = {
showPopup: false,
buttonTitle: 'Open Popup',
touchCount: 0,
};

public constructor(props: any) {
Expand All @@ -47,7 +56,8 @@ class AnchoredPopupExample extends React.Component<
isOpen={this.state.showPopup}
onDismiss={this._onPopupDismissed}
target={this._textInput.current}
isLightDismissEnabled={true}
isLightDismissEnabled={false}
autoFocus={false}
horizontalOffset={10}
verticalOffset={10}>
<View
Expand All @@ -58,24 +68,58 @@ class AnchoredPopupExample extends React.Component<
paddingTop: 10,
paddingBottom: 30,
}}>
This is a flyout
This is a popup
</Text>
<Button onPress={this._togglePopup} title="Close" />
{this.state.touchCount > 0 && (
<Text>I'm touched ({this.state.touchCount})</Text>
)}
<ScrollView>{this._renderTouchables()}</ScrollView>
</View>
</Popup>
)}
</View>
);
}

_renderTouchables = () => {
const touchables: JSX.Element[] = [];
for (let i = 0; i < 10; i++) {
touchables.push(
<TouchableHighlight
style={{
paddingTop: 10,
paddingBottom: 20,
borderWidth: 1,
borderColor: '#000000',
}}
onPress={this._highlightPressed}
underlayColor={'rgb(210, 230, 255)'}>
<View>
<Text>Click on the touchable</Text>
</View>
</TouchableHighlight>,
);
}

return touchables;
};

_togglePopup = () => {
this.setState(state => ({
buttonTitle: state.showPopup ? 'Open Popup' : 'Close Popup',
showPopup: !state.showPopup,
touchCount: 0,
}));
};

_onPopupDismissed = () => {
this.setState({buttonTitle: 'Open Popup', showPopup: false});
this.setState({buttonTitle: 'Open Popup', showPopup: false, touchCount: 0});
};

_highlightPressed = () => {
console.log('Touchable Highlight pressed');
this.setState({touchCount: this.state.touchCount + 1});
};
}

Expand Down

0 comments on commit 93a31c0

Please sign in to comment.