Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix dgrid horizontal scroll on focus #1086

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ var Keyboard = declare(null, {
enableNavigation(this.contentNode);

this._debouncedEnsureRowScroll = miscUtil.debounce(this._ensureRowScroll, this);
this._debouncedEnsureColumnScroll = miscUtil.debounce(this._ensureColumnScroll, this);
},

removeRow: function(rowElement){
Expand Down Expand Up @@ -294,6 +295,19 @@ var Keyboard = declare(null, {
this.scrollTo({ y: rowElement.offsetTop - this.contentNode.offsetHeight + rowElement.offsetHeight });
}
},

_ensureColumnScroll: function (cellElement) {
// summary:
// Ensures that the entire cell is visible in the viewport, such as when
// the grid has a horizontal scroll
var scrollX = this.getScrollPosition().x;
if (scrollX > cellElement.offsetLeft) {
this.scrollTo({ x: cellElement.offsetLeft });
}
else if (scrollX + this.contentNode.offsetWidth <= cellElement.offsetLeft + cellElement.offsetWidth + cellElement.clientLeft) {
this.scrollTo({ x: cellElement.offsetLeft + this.contentNode.offsetWidth + cellElement.offsetWidth });
}
},

_focusOnNode: function(element, isHeader, event){
var focusedNodeProperty = "_focused" + (isHeader ? "Header" : "") + "Node",
Expand Down Expand Up @@ -384,6 +398,8 @@ var Keyboard = declare(null, {
if(this.cellNavigation && (this.columnSets || this.subRows.length > 1) && !isHeader){
this._debouncedEnsureRowScroll(cell.row.element);
}

this._debouncedEnsureColumnScroll(cell.element);
},

focusHeader: function(element){
Expand Down Expand Up @@ -559,4 +575,4 @@ Keyboard.defaultHeaderKeyMap = {
};

return Keyboard;
});
});