0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-01 02:41:39 -05:00

Improved shift selection when deselecting items

refs https://github.com/TryGhost/Team/issues/2677

When deselecting all items, and then using shift, it still tries to shift between the previous selection. This fixes that issue.
This commit is contained in:
Simon Backx 2023-04-13 10:20:56 +02:00
parent c6220aad67
commit e3105bdde4

View file

@ -91,12 +91,27 @@ export default class SelectionList {
toggleItem(id) {
this.lastShiftSelectionGroup = new Set();
this.lastSelectedId = id;
if (this.selectedIds.has(id)) {
this.selectedIds.delete(id);
if (!this.inverted) {
if (this.lastSelectedId === id) {
this.lastSelectedId = null;
}
} else {
// Shift behaviour in inverted mode needs a review
this.lastSelectedId = id;
}
} else {
this.selectedIds.add(id);
if (!this.inverted) {
this.lastSelectedId = id;
} else {
// Shift behaviour in inverted mode needs a review
this.lastSelectedId = id;
}
}
// Force update
@ -168,10 +183,12 @@ export default class SelectionList {
selectAll() {
this.selectedIds = new Set();
this.inverted = !this.inverted;
this.lastSelectedId = null;
}
clearSelection() {
this.selectedIds = new Set();
this.inverted = false;
this.lastSelectedId = null;
}
}