From 5bd0eddb7cd0c307e46c6eefd5ccdfa598c38bcd Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 2 May 2021 22:59:59 -0700 Subject: [PATCH] Prevent a media from opening a browser --- src/components/retweet.js | 2 +- src/components/tweet.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/retweet.js b/src/components/retweet.js index e898707..fbeb911 100644 --- a/src/components/retweet.js +++ b/src/components/retweet.js @@ -12,7 +12,7 @@ export default class Retweet extends Tweet { tab: PropTypes.string.isRequired, tweet: PropTypes.object.isRequired, onClick: PropTypes.func.isRequired, - openMediaInWindow: PropTypes.func.isRequired, + openMediaInWindow: PropTypes.func.isRequired, // Used in the superclass } render() { diff --git a/src/components/tweet.js b/src/components/tweet.js index 5140291..f83d6b0 100644 --- a/src/components/tweet.js +++ b/src/components/tweet.js @@ -53,8 +53,11 @@ export default class Tweet extends React.Component { return entities.media.map((media) => { if (media.type === 'photo' || media.type === 'video' || media.type === 'animated_gif') { return ( - - {this.props.openMediaInWindow(media)}} src={media.media_url} /> + + { + event.preventDefault(); + this.props.openMediaInWindow(media); + } } src={media.media_url} /> ); } else {