Skip to content

Commit

Permalink
fix(files): Focus filename input in new-node dialog when opened
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux authored and backportbot[bot] committed Apr 16, 2024
1 parent cfd7e99 commit 65d09bd
Showing 1 changed file with 18 additions and 1 deletion.
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

0 comments on commit 65d09bd

Please sign in to comment.