From 81c41f063fc3e0b4c109e7cc01bdae30af81e26a Mon Sep 17 00:00:00 2001
From: Paul Kaplan <pkaplan@media.mit.edu>
Date: Tue, 5 Dec 2017 16:25:00 -0500
Subject: [PATCH] Try to keep new custom procedure inputs in view

---
 src/containers/custom-procedures.jsx | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/containers/custom-procedures.jsx b/src/containers/custom-procedures.jsx
index 18b8fed85..e442cabae 100644
--- a/src/containers/custom-procedures.jsx
+++ b/src/containers/custom-procedures.jsx
@@ -49,8 +49,13 @@ class CustomProcedures extends React.Component {
             // Keep the block centered on the workspace
             const metrics = this.workspace.getMetrics();
             const {x, y} = this.mutationRoot.getRelativeToSurfaceXY();
-            const dx = (metrics.viewWidth / 2) - (this.mutationRoot.width / 2) - x;
             const dy = (metrics.viewHeight / 2) - (this.mutationRoot.height / 2) - y;
+            let dx = (metrics.viewWidth / 2) - (this.mutationRoot.width / 2) - x;
+            // If the procedure declaration is wider than the view width,
+            // keep the right-hand side of the procedure in view.
+            if (this.mutationRoot.width > metrics.viewWidth) {
+                dx = metrics.viewWidth - this.mutationRoot.width - x;
+            }
             this.mutationRoot.moveBy(dx, dy);
         });
         this.mutationRoot.domToMutation(this.props.mutator);
-- 
GitLab