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

Keyboard._restoreFocus() clears the active selection in 'extended' mode #902

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions Keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ var Keyboard = declare(null, {
// previously removed row, or to the nearest sibling otherwise.

var focusInfo = this._removedFocus,
oldTarget = this.row(focusInfo.rowId),
newTarget,
cell;

Expand All @@ -242,10 +243,11 @@ var Keyboard = declare(null, {
if(cell && cell.element){
newTarget = cell;
}
oldTarget = this.cell(focusInfo.rowId, focusInfo.columnId);
}
if(focusInfo.active && newTarget.element.offsetHeight !== 0){
// Row/cell was previously focused and is visible, so focus the new one immediately
this.focus(newTarget);
this._focusOnNode(newTarget, false, { oldTarget: oldTarget.element });
}else{
// Row/cell was not focused or is not visible, but we still need to update tabIndex
// and the element's class to be consistent with the old one
Expand Down Expand Up @@ -517,4 +519,4 @@ Keyboard.defaultHeaderKeyMap = {
};

return Keyboard;
});
});
9 changes: 6 additions & 3 deletions Selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,13 @@ return declare(null, {
// except that clicks/keystrokes without modifier keys will clear
// the previous selection.

// Clear selection first for right-clicks outside selection and non-ctrl-clicks;
// otherwise, extended mode logic is identical to multiple mode
// Clear selection first for right-clicks outside selection and non-ctrl-clicks.
// For dgrid-cellfocusin events, do not clear the selection if our target is not
// changing, thus preserving the selection when the target receives a store update.
// Otherwise, extended mode logic is identical to multiple mode.
if(event.button === 2 ? !this.isSelected(target) :
!(event.keyCode ? event.ctrlKey : event[ctrlEquiv])){
!(event.keyCode ? event.ctrlKey : event[ctrlEquiv]) &&
!(event.oldTarget && event.oldTarget === target)){
this.clearSelection(null, true);
}
this._multipleSelectionHandler(event, target);
Expand Down