mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-11-10 15:22:03 +08:00
Bugfix: Selector Shift + Arrow made checkboxes "checked" in a weird way
This commit is contained in:
parent
ee5b30884f
commit
d1422826b8
1 changed files with 22 additions and 23 deletions
|
|
@ -12,6 +12,8 @@ import { koComputable } from 'External/ko';
|
||||||
UpOrDown
|
UpOrDown
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
let shiftStart;
|
||||||
|
|
||||||
export class Selector {
|
export class Selector {
|
||||||
/**
|
/**
|
||||||
* @param {koProperty} koList
|
* @param {koProperty} koList
|
||||||
|
|
@ -316,22 +318,31 @@ export class Selector {
|
||||||
*/
|
*/
|
||||||
newSelectPosition(sEventKey, bShiftKey, bForceSelect) {
|
newSelectPosition(sEventKey, bShiftKey, bForceSelect) {
|
||||||
let isArrow = 'ArrowUp' === sEventKey || 'ArrowDown' === sEventKey,
|
let isArrow = 'ArrowUp' === sEventKey || 'ArrowDown' === sEventKey,
|
||||||
result = null;
|
result;
|
||||||
|
|
||||||
const pageStep = 10,
|
const pageStep = 10,
|
||||||
list = this.list(),
|
list = this.list(),
|
||||||
listLen = list.length,
|
listLen = list.length,
|
||||||
focused = this.focusedItem();
|
focused = this.focusedItem();
|
||||||
|
|
||||||
if (listLen) {
|
if (' ' === sEventKey) {
|
||||||
|
focused?.checked(!focused.checked());
|
||||||
|
} else if (listLen) {
|
||||||
if (focused) {
|
if (focused) {
|
||||||
if (isArrow) {
|
if (isArrow) {
|
||||||
let i = list.indexOf(focused);
|
let i = list.indexOf(focused);
|
||||||
|
shiftStart = bShiftKey ? (-1 < shiftStart ? shiftStart : i) : -1;
|
||||||
|
shiftStart == i && focused.checked(true);
|
||||||
if ('ArrowUp' == sEventKey) {
|
if ('ArrowUp' == sEventKey) {
|
||||||
i > 0 && (result = list[i-1]);
|
bShiftKey && shiftStart < i && focused.checked(false);
|
||||||
} else if (++i < listLen) {
|
i > 0 && (result = list[--i]);
|
||||||
result = list[i];
|
} else {
|
||||||
|
bShiftKey && shiftStart > i && focused.checked(false);
|
||||||
|
if (++i < listLen) {
|
||||||
|
result = list[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
bShiftKey && result?.checked(true);
|
||||||
result || this.oCallbacks.UpOrDown?.('ArrowUp' === sEventKey);
|
result || this.oCallbacks.UpOrDown?.('ArrowUp' === sEventKey);
|
||||||
} else if ('Home' === sEventKey) {
|
} else if ('Home' === sEventKey) {
|
||||||
result = list[0];
|
result = list[0];
|
||||||
|
|
@ -359,26 +370,14 @@ export class Selector {
|
||||||
) {
|
) {
|
||||||
result = list[list.length - 1];
|
result = list[list.length - 1];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
this.focusedItem(result);
|
this.focusedItem(result);
|
||||||
|
if ((this.autoSelect() || bForceSelect) && !this.isListChecked()) {
|
||||||
if (focused && ((bShiftKey && isArrow) || ' ' === sEventKey)) {
|
this.selectedItem(result);
|
||||||
focused.checked(!focused.checked());
|
}
|
||||||
|
this.scrollToFocused();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (' ' !== sEventKey && (this.autoSelect() || bForceSelect) && !this.isListChecked()) {
|
|
||||||
this.selectedItem(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.scrollToFocused();
|
|
||||||
} else if (focused) {
|
|
||||||
if ((bShiftKey && isArrow) || ' ' === sEventKey) {
|
|
||||||
focused.checked(!focused.checked());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.focusedItem(focused);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue