From 0b8886d6e54b01e457833e975f4cbcadef2f91b0 Mon Sep 17 00:00:00 2001 From: Min RK Date: Thu, 10 Dec 2015 23:59:35 +0100 Subject: [PATCH] contract selection on click During multi-select, clicking on the current cell collapses the selection back to just that cell. --- notebook/static/notebook/js/cell.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/notebook/static/notebook/js/cell.js b/notebook/static/notebook/js/cell.js index fc67293fd..810fdf4c9 100644 --- a/notebook/static/notebook/js/cell.js +++ b/notebook/static/notebook/js/cell.js @@ -160,11 +160,14 @@ define([ * if just codemirror focus (so edit mode). * We **might** be able to move that to notebook `handle_edit_mode`. */ - Cell.prototype._on_click = function(event){ + Cell.prototype._on_click = function (event) { if (!this.selected) { this.events.trigger('select.Cell', {'cell':this, 'extendSelection':event.shiftKey}); + } else { + // I'm already part of the selection; contract selection to just me + this.events.trigger('select.Cell', {'cell': this}); } - } + }; /** * Subclasses can implement override bind_events. @@ -176,7 +179,7 @@ define([ var that = this; // We trigger events so that Cell doesn't have to depend on Notebook. that.element.click(function (event) { - that._on_click(event) + that._on_click(event); }); if (this.code_mirror) { this.code_mirror.on("change", function(cm, change) {