From a67fb22bee484a7bd2b4e727773b9f861c4fc2b4 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Thu, 3 Mar 2022 16:41:34 +0100 Subject: [PATCH] Improved Contacts popup close handling --- dev/View/Popup/Contacts.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/dev/View/Popup/Contacts.js b/dev/View/Popup/Contacts.js index 89f9f4988..c75b50157 100644 --- a/dev/View/Popup/Contacts.js +++ b/dev/View/Popup/Contacts.js @@ -1,9 +1,8 @@ import { koArrayWithDestroy } from 'External/ko'; import { SaveSettingsStep } from 'Common/Enums'; - import { ComposeType } from 'Common/EnumsUser'; - +import { doc } from 'Common/Globals'; import { arrayLength, pInt } from 'Common/Utils'; import { download, computedPaginatorHelper, showMessageComposer } from 'Common/UtilsUser'; @@ -20,9 +19,11 @@ import { EmailModel } from 'Model/Email'; import { ContactModel } from 'Model/Contact'; import { ContactPropertyModel, ContactPropertyType } from 'Model/ContactProperty'; -import { decorateKoCommands } from 'Knoin/Knoin'; +import { decorateKoCommands, showScreenPopup } from 'Knoin/Knoin'; import { AbstractViewPopup } from 'Knoin/AbstractViews'; +import { AskPopupView } from 'View/Popup/Ask'; + const CONTACTS_PER_PAGE = 50, ScopeContacts = 'Contacts', @@ -448,6 +449,9 @@ export class ContactsPopupView extends AbstractViewPopup { this.selector.init(dom.querySelector('.b-list-content'), ScopeContacts); shortcuts.add('delete', '', ScopeContacts, () => { + if (doc.activeElement && doc.activeElement.matches('input,textarea')) { + return true; + } this.deleteCommand(); return false; }); @@ -491,6 +495,16 @@ export class ContactsPopupView extends AbstractViewPopup { } } + onClose() { + if (this.watchDirty() && AskPopupView.hidden()) { + showScreenPopup(AskPopupView, [ + i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), + () => this.closeCommand() + ]); + return false; + } + } + onShow(bBackToCompose, sLastComposeFocusedField) { this.bBackToCompose = !!bBackToCompose; this.sLastComposeFocusedField = sLastComposeFocusedField;