Bugfix: compose mail select contacts for cc/bcc failed

Cleanup: Inputosaurus and Knockout
Change: Knockout domData now uses WeakMap
Replaced: Knockout domManipulation with a documentFragment
This commit is contained in:
djmaze 2021-02-01 14:34:24 +01:00
parent fe7c7fede4
commit ebe2c0536f
23 changed files with 410 additions and 889 deletions

View file

@ -68,7 +68,7 @@ ko.bindingHandlers.emailsTags = {
inputDelimiters = [',', ';', '\n'];
element.inputosaurus = new window.Inputosaurus(element, {
focusCallback: value => fValue && fValue.focused && fValue.focused(!!value),
focusCallback: value => fValue.focused && fValue.focused(!!value),
autoCompleteSource: fAllBindings.autoCompleteSource || null,
splitHook: value => {
const v = value.trim();
@ -89,7 +89,7 @@ ko.bindingHandlers.emailsTags = {
}
});
if (fValue && fValue.focused && fValue.focused.subscribe) {
if (fValue.focused && fValue.focused.subscribe) {
fValue.focused.subscribe(value =>
element.inputosaurus[value ? 'focus' : 'blur']()
);

View file

@ -142,16 +142,11 @@ class ComposePopupView extends AbstractViewPopup {
identitiesDropdownTrigger: false,
to: '',
toFocused: false,
cc: '',
ccFocused: false,
bcc: '',
bccFocused: false,
replyTo: '',
replyToFocused: false,
subject: '',
subjectFocused: false,
isHtml: false,
@ -197,20 +192,13 @@ class ComposePopupView extends AbstractViewPopup {
// this.to.subscribe((v) => console.log(v));
ko.computed(() => {
switch (true) {
case this.toFocused():
this.sLastFocusedField = 'to';
break;
case this.ccFocused():
this.sLastFocusedField = 'cc';
break;
case this.bccFocused():
this.sLastFocusedField = 'bcc';
break;
// no default
}
}).extend({ notify: 'always' });
// Used by ko.bindingHandlers.emailsTags
this.to.focused = ko.observable(false);
this.to.focused.subscribe(value => value && (this.sLastFocusedField = 'to'));
this.cc.focused = ko.observable(false);
this.cc.focused.subscribe(value => value && (this.sLastFocusedField = 'cc'));
this.bcc.focused = ko.observable(false);
this.bcc.focused.subscribe(value => value && (this.sLastFocusedField = 'bcc'));
this.attachments = ko.observableArray();
@ -688,7 +676,7 @@ class ComposePopupView extends AbstractViewPopup {
this.bSkipNextHide = false;
this.toFocused(false);
this.to.focused(false);
rl.route.on();
@ -1131,11 +1119,9 @@ class ComposePopupView extends AbstractViewPopup {
// rl.settings.app('mobile') ||
setTimeout(() => {
if (!this.to()) {
this.toFocused(true);
} else if (this.oEditor) {
if (!this.toFocused()) {
this.oEditor.focus();
}
this.to.focused(true);
} else if (this.oEditor && !this.to.focused()) {
this.oEditor.focus();
}
}, 100);
}