about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/components/permalink.js
diff options
context:
space:
mode:
authorpluralcafe-docker <git@plural.cafe>2018-10-13 01:09:02 +0000
committerpluralcafe-docker <git@plural.cafe>2018-10-13 01:09:02 +0000
commit7c96ee7815c216d6ac3b748d7dd6959376d3914e (patch)
treefd36bade02afa1536198e7f3beafb208973b68c5 /app/javascript/flavours/glitch/components/permalink.js
parentf9275cb762a311cbf298b3929552a153703c0726 (diff)
parent70d346ea951ebfa002225759310d72882a435a5c (diff)
Merge branch 'glitch'
Diffstat (limited to 'app/javascript/flavours/glitch/components/permalink.js')
-rw-r--r--app/javascript/flavours/glitch/components/permalink.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/app/javascript/flavours/glitch/components/permalink.js b/app/javascript/flavours/glitch/components/permalink.js
index d6556b584..1ea6a2915 100644
--- a/app/javascript/flavours/glitch/components/permalink.js
+++ b/app/javascript/flavours/glitch/components/permalink.js
@@ -12,12 +12,20 @@ export default class Permalink extends React.PureComponent {
     href: PropTypes.string.isRequired,
     to: PropTypes.string.isRequired,
     children: PropTypes.node,
+    onInterceptClick: PropTypes.func,
   };
 
   handleClick = (e) => {
-    if (this.context.router && e.button === 0 && !(e.ctrlKey || e.metaKey)) {
-      e.preventDefault();
-      this.context.router.history.push(this.props.to);
+    if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
+      if (this.props.onInterceptClick && this.props.onInterceptClick()) {
+        e.preventDefault();
+        return;
+      }
+
+      if (this.context.router) {
+        e.preventDefault();
+        this.context.router.history.push(this.props.to);
+      }
     }
   }
 
@@ -27,6 +35,7 @@ export default class Permalink extends React.PureComponent {
       className,
       href,
       to,
+      onInterceptClick,
       ...other
     } = this.props;