Prevent loss of selected characters when closing menu
This commit is contained in:
parent
b8540a190b
commit
fa452e94b0
|
@ -289,6 +289,13 @@ class BulkEditOverlay {
|
||||||
#stateChangeCallbacks = [];
|
#stateChangeCallbacks = [];
|
||||||
#selectedCharacters = [];
|
#selectedCharacters = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If ture, prevents items from being deselected by clicking anywhere
|
||||||
|
*
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
#selectModeLock = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type HTMLElement
|
* @type HTMLElement
|
||||||
*/
|
*/
|
||||||
|
@ -376,6 +383,7 @@ class BulkEditOverlay {
|
||||||
switch (this.state) {
|
switch (this.state) {
|
||||||
case BulkEditOverlayState.browse:
|
case BulkEditOverlayState.browse:
|
||||||
this.container.classList.remove(BulkEditOverlay.selectModeClass);
|
this.container.classList.remove(BulkEditOverlay.selectModeClass);
|
||||||
|
this.#selectModeLock = false;
|
||||||
this.#enableClickEventsForCharacters();
|
this.#enableClickEventsForCharacters();
|
||||||
this.#enableClickEventsForGroups();
|
this.#enableClickEventsForGroups();
|
||||||
this.clearSelectedCharacters();
|
this.clearSelectedCharacters();
|
||||||
|
@ -439,10 +447,13 @@ class BulkEditOverlay {
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.isLongPress && !cancel) {
|
if (this.isLongPress && !cancel) {
|
||||||
if (this.state === BulkEditOverlayState.browse)
|
if (this.state === BulkEditOverlayState.browse) {
|
||||||
this.selectState();
|
this.selectState();
|
||||||
else if (this.state === BulkEditOverlayState.select)
|
}
|
||||||
|
else if (this.state === BulkEditOverlayState.select) {
|
||||||
|
this.#selectModeLock = true;
|
||||||
CharacterContextMenu.show(...this.#getContextMenuPosition(event));
|
CharacterContextMenu.show(...this.#getContextMenuPosition(event));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.container.removeEventListener('mouseup', cancelHold);
|
this.container.removeEventListener('mouseup', cancelHold);
|
||||||
|
@ -452,10 +463,12 @@ class BulkEditOverlay {
|
||||||
|
|
||||||
handleLongPressEnd = () => {
|
handleLongPressEnd = () => {
|
||||||
this.isLongPress = false;
|
this.isLongPress = false;
|
||||||
|
if (this.#selectModeLock) event.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleCancelClick = () => {
|
handleCancelClick = () => {
|
||||||
this.state = BulkEditOverlayState.browse;
|
if (false === this.#selectModeLock) this.state = BulkEditOverlayState.browse;
|
||||||
|
this.#selectModeLock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -497,21 +510,23 @@ class BulkEditOverlay {
|
||||||
|
|
||||||
const legacyBulkEditCheckbox = character.querySelector('.' + BulkEditOverlay.legacySelectedClass);
|
const legacyBulkEditCheckbox = character.querySelector('.' + BulkEditOverlay.legacySelectedClass);
|
||||||
|
|
||||||
if (alreadySelected) {
|
if (!this.#selectModeLock)
|
||||||
character.classList.remove(BulkEditOverlay.selectedClass);
|
if (alreadySelected) {
|
||||||
if (legacyBulkEditCheckbox) legacyBulkEditCheckbox.checked = false;
|
character.classList.remove(BulkEditOverlay.selectedClass);
|
||||||
this.dismissCharacter(characterId);
|
if (legacyBulkEditCheckbox) legacyBulkEditCheckbox.checked = false;
|
||||||
} else {
|
this.dismissCharacter(characterId);
|
||||||
character.classList.add(BulkEditOverlay.selectedClass)
|
} else {
|
||||||
if (legacyBulkEditCheckbox) legacyBulkEditCheckbox.checked = true;
|
character.classList.add(BulkEditOverlay.selectedClass)
|
||||||
this.selectCharacter(characterId);
|
if (legacyBulkEditCheckbox) legacyBulkEditCheckbox.checked = true;
|
||||||
}
|
this.selectCharacter(characterId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleContextMenuShow = (event) => {
|
handleContextMenuShow = (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.container.style.pointerEvents = 'none';
|
this.container.style.pointerEvents = 'none';
|
||||||
CharacterContextMenu.show(...this.#getContextMenuPosition(event));
|
CharacterContextMenu.show(...this.#getContextMenuPosition(event));
|
||||||
|
this.#selectModeLock = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleContextMenuHide = (event) => {
|
handleContextMenuHide = (event) => {
|
||||||
|
|
Loading…
Reference in New Issue