@@ -2487,6 +2487,13 @@ export class Notebook extends StaticNotebook {
24872487 }
24882488 // Enter selecting mode
24892489 this . _mouseMode = 'select' ;
2490+
2491+ // We don't want to block the shift-click mouse up handler
2492+ // when the current cell is (and remains) the active cell.
2493+ this . _selectData = {
2494+ startedOnActiveCell : index == this . activeCellIndex ,
2495+ startingCellIndex : this . activeCellIndex
2496+ } ;
24902497 document . addEventListener ( 'mouseup' , this , true ) ;
24912498 document . addEventListener ( 'mousemove' , this , true ) ;
24922499 } else if ( button === 0 && ! shiftKey ) {
@@ -2532,8 +2539,21 @@ export class Notebook extends StaticNotebook {
25322539 * Handle the `'mouseup'` event on the document.
25332540 */
25342541 private _evtDocumentMouseup ( event : MouseEvent ) : void {
2535- event . preventDefault ( ) ;
2536- event . stopPropagation ( ) ;
2542+ const [ , index ] = this . _findEventTargetAndCell ( event ) ;
2543+
2544+ let shouldPreventDefault = true ;
2545+ if ( this . _mouseMode === 'select' && this . _selectData ) {
2546+ // User did not move the mouse over to a difference cell, so there was no selection
2547+ const { startedOnActiveCell, startingCellIndex } = this . _selectData ;
2548+ if ( startedOnActiveCell && index === startingCellIndex ) {
2549+ shouldPreventDefault = false ;
2550+ }
2551+ this . _selectData = null ;
2552+ }
2553+ if ( shouldPreventDefault ) {
2554+ event . preventDefault ( ) ;
2555+ event . stopPropagation ( ) ;
2556+ }
25372557
25382558 // Remove the event listeners we put on the document
25392559 document . removeEventListener ( 'mousemove' , this , true ) ;
@@ -2542,8 +2562,6 @@ export class Notebook extends StaticNotebook {
25422562 if ( this . _mouseMode === 'couldDrag' ) {
25432563 // We didn't end up dragging if we are here, so treat it as a click event.
25442564
2545- const [ , index ] = this . _findEventTargetAndCell ( event ) ;
2546-
25472565 this . deselectAll ( ) ;
25482566 this . activeCellIndex = index ;
25492567 // Focus notebook if active cell changes but does not have focus.
@@ -2955,6 +2973,10 @@ export class Notebook extends StaticNotebook {
29552973 pressY : number ;
29562974 index : number ;
29572975 } | null = null ;
2976+ private _selectData : {
2977+ startedOnActiveCell : boolean ;
2978+ startingCellIndex : number ;
2979+ } | null = null ;
29582980 private _mouseMode : 'select' | 'couldDrag' | null = null ;
29592981 private _activeCellChanged = new Signal < this, Cell | null > ( this ) ;
29602982 private _stateChanged = new Signal < this, IChangedArgs < any > > ( this ) ;
0 commit comments