Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Wait for mouseup event when clicking on a row/cell that is already se…

…lected, so as to make it possible to do dnd properly.
  • Loading branch information...
commit cd03213ea6cf9b67281405d1d0d912a808743cde 1 parent b7491c8
@kriszyp authored
Showing with 11 additions and 5 deletions.
  1. +11 −5 Selection.js
View
16 Selection.js
@@ -14,7 +14,7 @@ return declare([List], {
// selectionEvents: String
// Event (or events, comma-delimited) to listen on to trigger select logic.
// Note: this is ignored in the case of touch devices.
- selectionEvents: "mousedown,dgrid-cellfocusin",
+ selectionEvents: "mousedown,mouseup,dgrid-cellfocusin",
// deselectOnRefresh: Boolean
// If true, the selection object will be cleared when refresh is called.
@@ -62,12 +62,14 @@ return declare([List], {
// don't run if selection mode is none,
// or if coming from a dgrid-cellfocusin from a mousedown
if(this.selectionMode == "none" ||
- (event.type == "dgrid-cellfocusin" && event.parentType == "mousedown")){
+ (event.type == "dgrid-cellfocusin" && event.parentType == "mousedown") ||
+ (event.type == "mouseup" && currentTarget != this._waitForMouseUp)){
return;
}
+ this._waitForMouseUp = null;
- var ctrlKey = event.type == "mousedown" ? event[ctrlEquiv] : event.ctrlKey;
- if(event.type == "mousedown" || !event.ctrlKey || event.keyCode == 32){
+ var ctrlKey = !event.keyCode ? event[ctrlEquiv] : event.ctrlKey;
+ if(!event.keyCode || !event.ctrlKey || event.keyCode == 32){
var mode = this.selectionMode,
row = currentTarget,
rowObj = this.row(row),
@@ -84,6 +86,10 @@ return declare([List], {
this.select(row);
}
this._lastSelected = row;
+ }else if(this.selection[rowObj.id] && !event.shiftKey && event.type == "mousedown"){
+ // we wait for the mouse up if we are clicking a selected item so that drag n' drop
+ // is possible without losing our selection
+ this._waitForMouseUp = row;
}else{
var value;
// clear selection first for non-ctrl-clicks in extended mode,
@@ -104,7 +110,7 @@ return declare([List], {
this._lastSelected = row;
}
}
- if(event.type == "mousedown" && (event.shiftKey || ctrlKey)){
+ if(!event.keyCode && (event.shiftKey || ctrlKey)){
// prevent selection in firefox
event.preventDefault();
}
Please sign in to comment.
Something went wrong with that request. Please try again.