Permalink
Browse files

Fixed issue where the copy item would be added to the tooltips on the…

Summary:
This PR solves issue #13618.

Selectable text still behaves the same way:

```jsx
<Text selectable={true}>yo yo yo</Text>
```

![capture d ecran 2017-04-21 a 17 10 51](https://cloud.githubusercontent.com/assets/671923/25296285/85eba646-26b5-11e7-8773-e5e55ee0d7bb.png)

Text that is not selectable and has a custom tooltip now do not include the copy item:

```jsx
import * as React from 'react';
import { Text } from 'react-native';
import ToolTip from 'react-native-tooltip';

const MyComponent = () => (
  <Text>
    <Text>This is my text.</Text>
    <ToolTip
      actions={[
        {text: 'My', onPress: (): any => null },
        {text: 'Context', onPress: (): any => null },
        {text: 'Menu', onPress: (): any => null },
      ]}
      underlayColor='transparent'
      longPress={true}
      arrowDirection='down'
    >
      <Text>You can long press me for a tooltip.</Text>
    </ToolTip>
    <Text>This is the rest of my text</Text>
  </Text>
);

export default MyComponent;
```

![capture d ecran 2017-04-21 a 17 10 56](https://cloud.githubusercontent.com/assets/671923/25296297/970949ba-26b5-11e7-8378-3bf0289d1a5a.png)
Closes #13619

Reviewed By: shergin

Differential Revision: D4936900

Pulled By: ericvicenti

fbshipit-source-id: 82028b0958c37d63b8a80882196295be4aebecb4
  • Loading branch information...
gabrielbull authored and facebook-github-bot committed Apr 27, 2017
1 parent c8bb422 commit d5a61525822f2844119b3544b5b0af51da742026
Showing with 3 additions and 3 deletions.
  1. +3 −3 Libraries/Text/RCTText.m
View
@@ -236,11 +236,11 @@ - (BOOL)canBecomeFirstResponder
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
if (action == @selector(copy:)) {
if (_selectable && action == @selector(copy:)) {
return YES;
}
return [super canPerformAction:action withSender:sender];
return [self.nextResponder canPerformAction:action withSender:sender];
}
- (void)copy:(id)sender

0 comments on commit d5a6152

Please sign in to comment.