-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Allow pointer events on selectable Text #7813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3f86d76
Allow pointer events on selectable Text
rozele 1af10cf
Change files
rozele 6a3e8fc
Handle overrides of PointerCaptureLost events to emit `onTouchEnd` as…
rozele ad7ad48
yarn lint --fix
rozele 8409839
Merge branch 'main' of https://github.com/microsoft/react-native-wind…
NickGerleman 4c50a0c
yarn format
NickGerleman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/react-native-windows-8d2055e1-81e4-41ad-8d20-8eec501733b3.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "prerelease", | ||
| "comment": "Allow pointer events on selectable Text", | ||
| "packageName": "react-native-windows", | ||
| "email": "erozell@outlook.com", | ||
| "dependentChangeType": "patch" | ||
| } |
74 changes: 74 additions & 0 deletions
74
...s/@react-native-windows/tester/src/js/examples-win/LegacyTests/SelectableTextTestPage.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /** | ||
| * Copyright (c) Microsoft Corporation. | ||
| * Licensed under the MIT License. | ||
| * @format | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import {Button, StyleSheet, Text, View} from 'react-native'; | ||
|
|
||
| interface IPressableTextState { | ||
| count: number; | ||
| isSelectable: boolean; | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { | ||
| alignItems: 'flex-start', | ||
| }, | ||
| pressable: { | ||
| color: 'blue', | ||
| textDecorationLine: 'underline', | ||
| }, | ||
| }); | ||
|
|
||
| export class SelectableTextTests extends React.Component< | ||
| {}, | ||
| IPressableTextState | ||
| > { | ||
| constructor(props: any) { | ||
| super(props); | ||
| this.state = { | ||
| count: 0, | ||
| isSelectable: false, | ||
| }; | ||
| } | ||
| public render() { | ||
| const increment = () => this.setState({count: this.state.count + 1}); | ||
| return ( | ||
| <View style={styles.container}> | ||
| <Text testID="pressed-state">Pressed: {this.state.count} times.</Text> | ||
| <Text testID="text-example" selectable={this.state.isSelectable}> | ||
| Text before{' '} | ||
| <Text onPress={increment} style={styles.pressable}> | ||
| click here | ||
| </Text>{' '} | ||
| text after | ||
| </Text> | ||
| <Button | ||
| testID="toggle-selectable-button" | ||
| title="Toggle Selectable" | ||
| onPress={() => | ||
| this.setState({isSelectable: !this.state.isSelectable}) | ||
| } | ||
| /> | ||
| <Button | ||
| testID="clear-state-button" | ||
| title="Clear State" | ||
| onPress={() => this.setState({count: 0, isSelectable: false})} | ||
| /> | ||
| </View> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| export const displayName = (_undefined?: string) => {}; | ||
| export const title = 'LegacySelectableTextTest'; | ||
| export const description = 'Legacy e2e test for selectable Text hit testing'; | ||
| export const examples = [ | ||
| { | ||
| render: function(): JSX.Element { | ||
| return <SelectableTextTests />; | ||
| }, | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
packages/e2e-test-app/test/LegacySelectableTextTest.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /** | ||
| * Copyright (c) Microsoft Corporation. | ||
| * Licensed under the MIT License. | ||
| * | ||
| * @format | ||
| */ | ||
|
|
||
| import {app} from '@react-native-windows/automation'; | ||
| import {dumpVisualTree} from '@react-native-windows/automation-commands'; | ||
| import {goToComponentExample} from './RNTesterNavigation'; | ||
|
|
||
| beforeAll(async () => { | ||
| await goToComponentExample('LegacySelectableTextTest'); | ||
| }); | ||
|
|
||
| describe('LegacySelectableTextTest', () => { | ||
| beforeEach(async () => { | ||
| await clearState(); | ||
| }); | ||
|
|
||
| test('PressableWhenNotSelectable', async () => { | ||
| const textExample = await app.findElementByTestID('text-example'); | ||
| await textExample.click(); | ||
| const dump = await dumpVisualTree('pressed-state'); | ||
| expect(dump).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| test('DoubleClickWhenNotSelectable', async () => { | ||
| const textExample = await app.findElementByTestID('text-example'); | ||
| await textExample.doubleClick(); | ||
| const dump = await dumpVisualTree('pressed-state'); | ||
| expect(dump).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| test('PressableWhenSelectable', async () => { | ||
| await toggleSelectable(); | ||
| const textExample = await app.findElementByTestID('text-example'); | ||
| await textExample.click(); | ||
| const dump = await dumpVisualTree('pressed-state'); | ||
| expect(dump).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| test('DoubleClickWhenSelectable', async () => { | ||
| await toggleSelectable(); | ||
| const textExample = await app.findElementByTestID('text-example'); | ||
| await textExample.doubleClick(); | ||
| const dump = await dumpVisualTree('pressed-state'); | ||
| expect(dump).toMatchSnapshot(); | ||
| }); | ||
| }); | ||
|
|
||
| async function clearState() { | ||
| const clearButton = await app.findElementByTestID('clear-state-button'); | ||
| await clearButton.click(); | ||
| } | ||
|
|
||
| async function toggleSelectable() { | ||
| const toggleButton = await app.findElementByTestID( | ||
| 'toggle-selectable-button', | ||
| ); | ||
| await toggleButton.click(); | ||
| } |
81 changes: 81 additions & 0 deletions
81
packages/e2e-test-app/test/__snapshots__/LegacySelectableTextTest.test.ts.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`LegacySelectableTextTest DoubleClickWhenNotSelectable 1`] = ` | ||
| Object { | ||
| "AutomationId": "pressed-state", | ||
| "Clip": null, | ||
| "FlowDirection": "LeftToRight", | ||
| "Foreground": "#E4000000", | ||
| "Height": 19, | ||
| "HorizontalAlignment": "Stretch", | ||
| "Left": 0, | ||
| "Margin": "0,0,0,0", | ||
| "Padding": "0,0,0,0", | ||
| "Text": "Pressed: 2 times.", | ||
| "Top": 0, | ||
| "VerticalAlignment": "Stretch", | ||
| "Visibility": "Visible", | ||
| "Width": 103, | ||
| "XamlType": "Windows.UI.Xaml.Controls.TextBlock", | ||
| } | ||
| `; | ||
|
|
||
| exports[`LegacySelectableTextTest DoubleClickWhenSelectable 1`] = ` | ||
| Object { | ||
| "AutomationId": "pressed-state", | ||
| "Clip": null, | ||
| "FlowDirection": "LeftToRight", | ||
| "Foreground": "#E4000000", | ||
| "Height": 19, | ||
| "HorizontalAlignment": "Stretch", | ||
| "Left": 0, | ||
| "Margin": "0,0,0,0", | ||
| "Padding": "0,0,0,0", | ||
| "Text": "Pressed: 1 times.", | ||
| "Top": 0, | ||
| "VerticalAlignment": "Stretch", | ||
| "Visibility": "Visible", | ||
| "Width": 103, | ||
| "XamlType": "Windows.UI.Xaml.Controls.TextBlock", | ||
| } | ||
| `; | ||
|
|
||
| exports[`LegacySelectableTextTest PressableWhenNotSelectable 1`] = ` | ||
| Object { | ||
| "AutomationId": "pressed-state", | ||
| "Clip": null, | ||
| "FlowDirection": "LeftToRight", | ||
| "Foreground": "#E4000000", | ||
| "Height": 19, | ||
| "HorizontalAlignment": "Stretch", | ||
| "Left": 0, | ||
| "Margin": "0,0,0,0", | ||
| "Padding": "0,0,0,0", | ||
| "Text": "Pressed: 1 times.", | ||
| "Top": 0, | ||
| "VerticalAlignment": "Stretch", | ||
| "Visibility": "Visible", | ||
| "Width": 103, | ||
| "XamlType": "Windows.UI.Xaml.Controls.TextBlock", | ||
| } | ||
| `; | ||
|
|
||
| exports[`LegacySelectableTextTest PressableWhenSelectable 1`] = ` | ||
| Object { | ||
| "AutomationId": "pressed-state", | ||
| "Clip": null, | ||
| "FlowDirection": "LeftToRight", | ||
| "Foreground": "#E4000000", | ||
| "Height": 19, | ||
| "HorizontalAlignment": "Stretch", | ||
| "Left": 0, | ||
| "Margin": "0,0,0,0", | ||
| "Padding": "0,0,0,0", | ||
| "Text": "Pressed: 1 times.", | ||
| "Top": 0, | ||
| "VerticalAlignment": "Stretch", | ||
| "Visibility": "Visible", | ||
| "Width": 103, | ||
| "XamlType": "Windows.UI.Xaml.Controls.TextBlock", | ||
| } | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.