0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

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 { } else {
this.selectionList.clearSelection(); this.selectionList.clearSelection();
this.selectionList.toggleItem(this.id); this.selectionList.toggleItem(this.id);
this.selectionList.clearOnNextUnfreeze();
this.dropdown.toggleDropdown('context-menu', this, {left: x, top: y, selectionList: this.selectionList}); 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; #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) { constructor(infinityModel) {
this.infinityModel = infinityModel ?? {content: []}; this.infinityModel = infinityModel ?? {content: []};
} }
@ -22,6 +27,14 @@ export default class SelectionList {
unfreeze() { unfreeze() {
this.#frozen = false; this.#frozen = false;
if (this.#clearOnNextUnfreeze) {
this.clearSelection();
this.#clearOnNextUnfreeze = false;
}
}
clearOnNextUnfreeze() {
this.#clearOnNextUnfreeze = true;
} }
/** /**