Automatically select text in rename-prompt

This commit is contained in:
Jan Oberhauser 2019-07-24 15:21:44 +02:00
parent 117630fb68
commit 132f32132a

View file

@ -1428,13 +1428,26 @@ export default mixins(
},
async renameNodePrompt (currentName: string) {
try {
const promptResponse = await this.$prompt('New Name:', `Rename Node: "${currentName}"`, {
const promptResponsePromise = this.$prompt('New Name:', `Rename Node: "${currentName}"`, {
customClass: 'rename-prompt',
confirmButtonText: 'Rename',
cancelButtonText: 'Cancel',
inputErrorMessage: 'Invalid Name',
inputValue: currentName,
});
// Wait till it had time to display
await Vue.nextTick();
// Get the input and select the text in it
const nameInput = document.querySelector('.rename-prompt .el-input__inner') as HTMLInputElement | undefined;
if (nameInput) {
nameInput.focus();
nameInput.select();
}
const promptResponse = await promptResponsePromise;
this.renameNode(currentName, promptResponse.value);
} catch (e) {}
},