Skip to content

EspoCRM – Open Source CRM Application

duration focus after update fix

Yuri Kuznetsovcc14c69a5e0b
diff --git a/client/src/ui/select.js b/client/src/ui/select.js
index 4a7505974d..43b17fed33 100644
--- a/client/src/ui/select.js
+++ b/client/src/ui/select.js
@@ -41,6 +41,7 @@ import Selectize from 'lib!selectize';
* searched items.
* @property {'value'|'text'|'$order'|'$score'} [sortBy='$order'] Item sorting.
* @property {'asc'|'desc'} [sortDirection='asc'] Sort direction.
+ * @property {function()} [onFocus] On-focus callback.
*/
/**
@@ -153,6 +154,12 @@ const Select = {
},
};
+ if (options.onFocus) {
+ selectizeOptions.onFocus = function () {
+ options.onFocus();
+ };
+ }
+
if (!options.matchAnyWord) {
/** @this Selectize */
selectizeOptions.score = function (search) {
diff --git a/client/src/views/fields/duration.js b/client/src/views/fields/duration.js
index 744b7392fc..be61d51e7d 100644
--- a/client/src/views/fields/duration.js
+++ b/client/src/views/fields/duration.js
@@ -38,6 +38,12 @@ class DurationFieldView extends EnumFieldView {
detailTemplate = 'fields/varchar/detail'
editTemplate = 'fields/duration/edit'
+ /**
+ * @private
+ * @type {boolean}
+ */
+ _justFocused = false
+
data() {
const valueIsSet = this.model.has(this.startField) && this.model.has(this.endField);
@@ -342,6 +348,10 @@ class DurationFieldView extends EnumFieldView {
callback(list);
},
+ onFocus: () => {
+ this._justFocused = true;
+ setTimeout(() => this._justFocused = false, 150);
+ },
});
}
}
@@ -435,7 +445,7 @@ class DurationFieldView extends EnumFieldView {
updateDuration() {
const seconds = this.seconds;
- if (this.isEditMode() && this.$duration && this.$duration.length) {
+ if (this.isEditMode() && this.$duration && this.$duration.length && !this._justFocused) {
const options = this.getOptions().map(value => {
return {
value: value.toString(),