Skip to content

Commit

Permalink
Fix #1147: ColumnResizer: Protect header cells from clicks on resize
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth G. Franqueiro committed Oct 30, 2015
1 parent 02a81eb commit 1ee518a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
9 changes: 9 additions & 0 deletions css/dgrid.css
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ html.has-mozilla .dgrid-focus {
border-right: 2px dotted #000 !important;
}
.dgrid-column-resizer {
cursor: col-resize;
position: absolute;
width: 2px;
background-color: #666;
Expand All @@ -262,6 +263,14 @@ html.has-mozilla .dgrid-focus {
.dgrid-resize-header-container {
height: 100%;
}
.dgrid-resize-guard {
cursor: col-resize;
position: absolute;
bottom: 0;
left: 0;
right: 0;
top: 0;
}
html.has-touch .dgrid-resize-handle {
border-left: 20px solid transparent;
}
Expand Down
11 changes: 11 additions & 0 deletions css/extensions/ColumnResizer.styl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.dgrid-column-resizer {
cursor: col-resize;
position: absolute;
width: 2px;
background-color: #666;
Expand All @@ -21,6 +22,16 @@
height:100%;
}

.dgrid-resize-guard {
// Used to prevent click events trickling down to the underlying header cell
cursor: col-resize;
position: absolute;
bottom: 0;
left: 0;
right: 0;
top: 0;
}

// make the resize handles larger on touch-capable devices
html.has-touch .dgrid-resize-handle {
border-left: 20px solid transparent;
Expand Down
8 changes: 7 additions & 1 deletion extensions/ColumnResizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,27 +138,32 @@ define([
// Functions for shared resizer node

var resizerNode, // DOM node for resize indicator, reused between instances
resizerGuardNode, // DOM node to guard against clicks registering on header cells (and inducing sort)
resizableCount = 0; // Number of ColumnResizer-enabled grid instances
var resizer = {
// This object contains functions for manipulating the shared resizerNode
create: function () {
resizerNode = domConstruct.create('div', { className: 'dgrid-column-resizer' });
resizerGuardNode = domConstruct.create('div', { className: 'dgrid-resize-guard' });
},
destroy: function () {
domConstruct.destroy(resizerNode);
resizerNode = null;
domConstruct.destroy(resizerGuardNode);
resizerNode = resizerGuardNode = null;
},
show: function (grid) {
var pos = geom.position(grid.domNode, true);
resizerNode.style.top = pos.y + 'px';
resizerNode.style.height = pos.h + 'px';
document.body.appendChild(resizerNode);
grid.domNode.appendChild(resizerGuardNode);
},
move: function (x) {
resizerNode.style.left = x + 'px';
},
hide: function () {
resizerNode.parentNode.removeChild(resizerNode);
resizerGuardNode.parentNode.removeChild(resizerGuardNode);
}
};

Expand Down Expand Up @@ -337,6 +342,7 @@ define([
// in all but IE < 9. setSelectable works for those.
e.preventDefault();
dom.setSelectable(this.domNode, false);

this._startX = this._getResizeMouseLocation(e); //position of the target

this._targetCell = query('.dgrid-column-' + miscUtil.escapeCssIdentifier(target.columnId, '-'),
Expand Down

0 comments on commit 1ee518a

Please sign in to comment.