diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-04-16 12:55:50 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-04-16 12:55:50 +0200 |
commit | dec0d91468c63a340b1f58471a869f0cfe696b6e (patch) | |
tree | e8f6bbb50690309ce9275696fc52f2eff122f124 /apps/files/src/components/NewNodeDialog.vue | |
parent | 90281375a3c9f991be79091450469cdfebc9277a (diff) | |
download | nextcloud-server-dec0d91468c63a340b1f58471a869f0cfe696b6e.tar.gz nextcloud-server-dec0d91468c63a340b1f58471a869f0cfe696b6e.zip |
fix(files): Focus filename input in new-node dialog when opened
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/files/src/components/NewNodeDialog.vue')
-rw-r--r-- | apps/files/src/components/NewNodeDialog.vue | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/apps/files/src/components/NewNodeDialog.vue b/apps/files/src/components/NewNodeDialog.vue index 38337ddf4b8..5947334f11b 100644 --- a/apps/files/src/components/NewNodeDialog.vue +++ b/apps/files/src/components/NewNodeDialog.vue @@ -128,14 +128,31 @@ export default defineComponent({ defaultName() { this.localDefaultName = this.defaultName || t('files', 'New folder') }, + + /** + * Ensure the input is focussed even if the dialog is already mounted but not open + */ + open() { + this.$nextTick(() => this.focusInput()) + }, }, mounted() { // on mounted lets use the unique name this.localDefaultName = this.uniqueName - this.$nextTick(() => (this.$refs.input as unknown as ICanFocus)?.focus?.()) + this.$nextTick(() => this.focusInput()) }, methods: { t, + + /** + * Focus the filename input field + */ + focusInput() { + if (this.open) { + this.$nextTick(() => (this.$refs.input as unknown as ICanFocus)?.focus?.()) + } + }, + onCreate() { this.$emit('close', this.localDefaultName) }, |