Merge pull request #44847 from nextcloud/fix/files-focus-new-node-dialog

fix(files): Focus filename input in new-node dialog when opened
This commit is contained in:
Ferdinand Thiessen 2024-04-16 13:57:32 +02:00 committed by GitHub
commit 33c4ddd640
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 1 deletions

View File

@ -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)
},

BIN
dist/files-init.js vendored

Binary file not shown.

BIN
dist/files-init.js.map vendored

Binary file not shown.