mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-08-14 09:43:22 -03:00
feat(delete): add undo toasts and harden delete modals
This commit is contained in:
@@ -434,6 +434,22 @@ export class ModalManager {
|
||||
this.currentOpenModal = id; // Update currently open modal
|
||||
document.body.style.top = `-${this.scrollPosition}px`;
|
||||
document.body.classList.add('modal-open');
|
||||
|
||||
modal.restoreFocusTo = null;
|
||||
if (this._isDeleteConfirmModal(modal.element)) {
|
||||
const activeElement = document.activeElement;
|
||||
modal.restoreFocusTo = activeElement && activeElement !== document.body
|
||||
? activeElement
|
||||
: null;
|
||||
modal.element.querySelector('.cancel-btn')?.focus();
|
||||
}
|
||||
}
|
||||
|
||||
// Several non-delete modals share the delete-modal styling class, so an
|
||||
// actual .delete-btn is required before focus is moved to Cancel.
|
||||
_isDeleteConfirmModal(element) {
|
||||
return element.classList.contains('delete-modal') &&
|
||||
Boolean(element.querySelector('.delete-btn'));
|
||||
}
|
||||
|
||||
closeModal(id) {
|
||||
@@ -463,6 +479,13 @@ export class ModalManager {
|
||||
modal.cleanupCallback();
|
||||
modal.cleanupCallback = null;
|
||||
}
|
||||
|
||||
if (modal.restoreFocusTo) {
|
||||
if (modal.restoreFocusTo.isConnected) {
|
||||
modal.restoreFocusTo.focus();
|
||||
}
|
||||
modal.restoreFocusTo = null;
|
||||
}
|
||||
}
|
||||
|
||||
handleEscape(e) {
|
||||
|
||||
Reference in New Issue
Block a user