Skip to content

Commit

Permalink
Merge pull request #44847 from nextcloud/fix/files-focus-new-node-dialog
Browse files Browse the repository at this point in the history
fix(files): Focus filename input in new-node dialog when opened
  • Loading branch information
susnux authored Apr 16, 2024
2 parents 7eec3b5 + 2163a83 commit 33c4ddd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
19 changes: 18 additions & 1 deletion apps/files/src/components/NewNodeDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
Expand Down
4 changes: 2 additions & 2 deletions dist/files-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-init.js.map

Large diffs are not rendered by default.

0 comments on commit 33c4ddd

Please sign in to comment.