mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
@@ -49,6 +49,7 @@
|
|||||||
hide-no-data
|
hide-no-data
|
||||||
return-object
|
return-object
|
||||||
class="chip-selector__input"
|
class="chip-selector__input"
|
||||||
|
@click:control="focusInput"
|
||||||
@keydown.enter.prevent="onEnter"
|
@keydown.enter.prevent="onEnter"
|
||||||
@blur="addNewItem"
|
@blur="addNewItem"
|
||||||
@update:model-value="onComboboxChange"
|
@update:model-value="onComboboxChange"
|
||||||
@@ -238,19 +239,8 @@ export default {
|
|||||||
onComboboxChange(value) {
|
onComboboxChange(value) {
|
||||||
if (value && typeof value === "object" && value.title) {
|
if (value && typeof value === "object" && value.title) {
|
||||||
this.newItemTitle = value;
|
this.newItemTitle = value;
|
||||||
|
this.temporarilyCloseMenu();
|
||||||
this.addNewItem();
|
this.addNewItem();
|
||||||
this.menuOpen = false;
|
|
||||||
// Immediately clear the input, remove focus and restore placeholder
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.newItemTitle = "";
|
|
||||||
if (this.$refs.inputField) {
|
|
||||||
this.$refs.inputField.blur();
|
|
||||||
// Force the combobox to reset completely
|
|
||||||
setTimeout(() => {
|
|
||||||
this.newItemTitle = null;
|
|
||||||
}, 10);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
this.newItemTitle = value;
|
this.newItemTitle = value;
|
||||||
}
|
}
|
||||||
@@ -341,24 +331,13 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.$emit("update:items", [...this.items, newItem]);
|
this.$emit("update:items", [...this.items, newItem]);
|
||||||
this.newItemTitle = null;
|
this.temporarilyCloseMenu();
|
||||||
this.menuOpen = false;
|
this.clearAndOptionallyRefocus(true);
|
||||||
|
|
||||||
// Refocus input field
|
|
||||||
this.$nextTick(() => {
|
|
||||||
if (this.$refs.inputField) {
|
|
||||||
this.$refs.inputField.focus();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onEnter() {
|
onEnter() {
|
||||||
this.suppressMenuOpen = true;
|
this.temporarilyCloseMenu();
|
||||||
this.menuOpen = false;
|
|
||||||
this.addNewItem();
|
this.addNewItem();
|
||||||
window.setTimeout(() => {
|
|
||||||
this.suppressMenuOpen = false;
|
|
||||||
}, 250);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onMenuUpdate(val) {
|
onMenuUpdate(val) {
|
||||||
@@ -368,20 +347,42 @@ export default {
|
|||||||
}
|
}
|
||||||
this.menuOpen = val;
|
this.menuOpen = val;
|
||||||
},
|
},
|
||||||
resetInputField() {
|
|
||||||
|
focusInput() {
|
||||||
|
if (this.$refs.inputField && typeof this.$refs.inputField.focus === "function") {
|
||||||
|
this.$refs.inputField.focus();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
temporarilyCloseMenu() {
|
||||||
this.menuOpen = false;
|
this.menuOpen = false;
|
||||||
|
this.suppressMenuOpen = true;
|
||||||
|
window.setTimeout(() => {
|
||||||
|
this.suppressMenuOpen = false;
|
||||||
|
}, 200);
|
||||||
|
},
|
||||||
|
|
||||||
|
clearAndOptionallyRefocus(shouldRefocus = false) {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.newItemTitle = "";
|
this.newItemTitle = "";
|
||||||
if (this.$refs.inputField) {
|
if (this.$refs.inputField) {
|
||||||
this.$refs.inputField.blur();
|
this.$refs.inputField.blur();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.newItemTitle = null;
|
this.newItemTitle = null;
|
||||||
|
if (shouldRefocus) {
|
||||||
|
this.focusInput();
|
||||||
|
}
|
||||||
}, 10);
|
}, 10);
|
||||||
} else {
|
} else {
|
||||||
this.newItemTitle = null;
|
this.newItemTitle = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
resetInputField() {
|
||||||
|
this.temporarilyCloseMenu();
|
||||||
|
this.clearAndOptionallyRefocus(false);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user