duration focus after update fix

This commit is contained in:
Yuri Kuznetsov
2025-03-06 13:56:00 +02:00
parent 01a40e311d
commit da14a41387
2 changed files with 18 additions and 1 deletions
+7
View File
@@ -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) {
+11 -1
View File
@@ -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(),