From 114e4504616cca47941aa87dc81d788c9a092221 Mon Sep 17 00:00:00 2001 From: Jaden Diefenbaugh <jaden.diefenbaugh@idiap.ch> Date: Tue, 15 May 2018 11:50:28 +0200 Subject: [PATCH] [toolchains] throttle clicking tc blocks to ignore doubleclicks, closes #107 --- .../components/toolchain/ToolchainEditor.jsx | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/conda/js/src/components/toolchain/ToolchainEditor.jsx b/conda/js/src/components/toolchain/ToolchainEditor.jsx index a6dbe35b..444cd63d 100644 --- a/conda/js/src/components/toolchain/ToolchainEditor.jsx +++ b/conda/js/src/components/toolchain/ToolchainEditor.jsx @@ -882,16 +882,23 @@ export class ToolchainEditor extends React.PureComponent<Props, State> { } } + lastClickMs = 0 // handles left clicking on a block handleBlockClick = (blockName: string, set: BlockSet) => { - const newMBI = { - set, - name: blockName, - active: true, - }; - this.setState({ - modalBlockInfo: newMBI, - }); + const currTime = Date.now(); + // 1sec throttling + const delay = 1000; + if(currTime - this.lastClickMs > delay){ + const newMBI = { + set, + name: blockName, + active: true, + }; + this.setState({ + modalBlockInfo: newMBI, + }); + } + this.lastClickMs = currTime; } // uses the server's /layout endpoint to get a graphviz layout for this toolchain -- GitLab