Added clear selection when right clicking non selected item

refs https://github.com/TryGhost/Team/issues/2677
This commit is contained in:
Simon Backx 2023-04-14 11:12:30 +02:00
parent 20d2722f04
commit 062a716fbc
2 changed files with 14 additions and 0 deletions

View File

@ -86,6 +86,7 @@ export default class ItemComponent extends Component {
} else {
this.selectionList.clearSelection();
this.selectionList.toggleItem(this.id);
this.selectionList.clearOnNextUnfreeze();
this.dropdown.toggleDropdown('context-menu', this, {left: x, top: y, selectionList: this.selectionList});
}

View File

@ -12,6 +12,11 @@ export default class SelectionList {
#frozen = false;
/**
* When doing right click on an item, we temporarily select it, but want to clear it as soon as we close the context menu.
*/
#clearOnNextUnfreeze = false;
constructor(infinityModel) {
this.infinityModel = infinityModel ?? {content: []};
}
@ -22,6 +27,14 @@ export default class SelectionList {
unfreeze() {
this.#frozen = false;
if (this.#clearOnNextUnfreeze) {
this.clearSelection();
this.#clearOnNextUnfreeze = false;
}
}
clearOnNextUnfreeze() {
this.#clearOnNextUnfreeze = true;
}
/**