From 7b0a68d9fedaf59718b11c78bf4dfda111d5d2eb Mon Sep 17 00:00:00 2001 From: Alexey Velikiy Date: Sat, 9 Feb 2019 19:56:04 +0300 Subject: [PATCH] fix: Necessary double button push for entering delete mode #173 --- src/panel/graph_panel/graph_ctrl.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/panel/graph_panel/graph_ctrl.ts b/src/panel/graph_panel/graph_ctrl.ts index 642a9e1..12baa9e 100644 --- a/src/panel/graph_panel/graph_ctrl.ts +++ b/src/panel/graph_panel/graph_ctrl.ts @@ -158,13 +158,19 @@ class GraphCtrl extends MetricsPanelCtrl { } - bindDKey() { - this.keybindingSrv.bind('d', this.onDKey.bind(this)); + rebindDKey() { + $(document).off('keydown.hasticDKey'); + $(document).on('keydown.hasticDKey', (e) => { + // 68 is 'd' key kode + if(e.keyCode === 68) { + this.onDKey(); + } + }); } editPanel() { super.editPanel(); - this.bindDKey(); + this.rebindDKey(); } async getBackendURL(): Promise { @@ -244,7 +250,7 @@ class GraphCtrl extends MetricsPanelCtrl { this.analyticsController = new AnalyticController(this.panel, this.analyticService, this.events); - this.bindDKey(); + this.rebindDKey(); this.events.on('render', this.onRender.bind(this)); this.events.on('data-received', this.onDataReceived.bind(this));