From b096ea0a03603049ffb30f2beecda3ee41f74cf0 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Tue, 11 Sep 2018 08:31:42 -0300 Subject: [PATCH] Fix iOS tap on post (#2095) --- .../markdown/markdown_image/markdown_image.js | 2 +- .../options_context/options_context.ios.js | 35 +++++++++++-------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/app/components/markdown/markdown_image/markdown_image.js b/app/components/markdown/markdown_image/markdown_image.js index df1f54fc1..8501256f1 100644 --- a/app/components/markdown/markdown_image/markdown_image.js +++ b/app/components/markdown/markdown_image/markdown_image.js @@ -149,7 +149,7 @@ export default class MarkdownImage extends React.Component { }; handleLinkCopy = () => { - Clipboard.setString(this.props.linkDestination); + Clipboard.setString(this.props.linkDestination || this.props.source); }; handlePreviewImage = () => { diff --git a/app/components/options_context/options_context.ios.js b/app/components/options_context/options_context.ios.js index 3fd7c88c1..615373967 100644 --- a/app/components/options_context/options_context.ios.js +++ b/app/components/options_context/options_context.ios.js @@ -27,6 +27,18 @@ export default class OptionsContext extends PureComponent { }; } + beforeShow = (additionalAction) => { + const nextActions = this.props.getPostActions(); + if (additionalAction && additionalAction.text && !additionalAction.nativeEvent) { + const copyPostIndex = nextActions.findIndex((action) => action.copyPost); + nextActions.splice(copyPostIndex + 1, 0, additionalAction); + } + + this.setState({ + actions: nextActions, + }); + }; + handleHide = () => { this.isShowing = false; this.props.toggleSelected(false); @@ -39,7 +51,7 @@ export default class OptionsContext extends PureComponent { }; handleShowUnderlay = () => { - this.show(); + this.beforeShow(); this.props.toggleSelected(true); this.isShowing = this.state.actions.length > 0; }; @@ -57,27 +69,20 @@ export default class OptionsContext extends PureComponent { this.props.toggleSelected(false); }; - show = (additionalAction) => { - const nextActions = this.props.getPostActions(); - if (additionalAction && additionalAction.text && !additionalAction.nativeEvent) { - const copyPostIndex = nextActions.findIndex((action) => action.copyPost); - nextActions.splice(copyPostIndex + 1, 0, additionalAction); - } + handlePress = () => { + this.props.toggleSelected(false); + this.props.onPress(); + }; - this.setState({ - actions: nextActions, - }); + show = (additionalAction) => { + this.props.toggleSelected(true); + this.beforeShow(additionalAction); if (this.refs.toolTip) { this.refs.toolTip.showMenu(); } }; - handlePress = () => { - this.props.toggleSelected(false); - this.props.onPress(); - }; - render() { return (