Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rn][win] Adds HyperlinkViewManager for
selectable
-safe onPress
Summary: When `selectable={true}` on the Text component in react-native-windows, the TextBlock native component captures and handles all pointer events, thus none of the pointer events are sent to JS. We could just allow the TouchEventHandler to respond to all events, even handled ones, but I'm concerned that this may raise other issues with other components that are expected to handle events (e.g., getting onPress events before ScrollViewer gets a chance to capture the pointer). There are other limitations to that approach as well, including issues with the mouse cursor and how the control would interoperate with accessibility. Adding Hyperlink works around this limitation as we can emit direct events that can be tied to a JS `onPress` callback via the `Click` event, which "plays nicely" with `selectable={true}`. Also, Hyperlink has expected behavior out of the box for focusability and pointer cursor. The reason this needs to be implemented in our fork and not in Zeratul is because the `IViewManager` interface exposed from the ABI for react-native-windows uses `FrameworkElement` as a base class, so we could not create a ViewManager for `Hyperlink`, which derives from `DependencyObject` and not `FrameworkElement`. Here are the GitHub issues tracking that this is working around: microsoft#1679 microsoft#5539 Test Plan: - Can we invoke onPress for FocusableText when selectable=true? https://pxl.cl/1G90F - Does the mouse cursor change from the selection IBeam to signal that the FocusableText can be clicked? {F564338487} - Can I still set selection on link text? {F564343437} - Can we tab focus to FocusableText? Not currently, but I believe this is not a limitation of the Hyperlink approach, something else seems to be trapping focus in the chat window. - Can we use the Enter key to invoke onPress for FocusableText? Not currently because the hyperlink cannot get focus. - Stretch: Is there any feedback when onPressIn for FocusableText? No, and it's likely that if someone adds it using `onPressIn` or `onPressOut` it will be broken. Reviewers: skyle, lyahdav, mylando Reviewed By: lyahdav Subscribers: necolas, eliwhite Differential Revision: https://phabricator.intern.facebook.com/D27474588 Tasks: T87521248 Signature: 27474588:1617305556:de80de6759c483628f86d3453533eacf360ce234
- Loading branch information