Skip to content

Commit

Permalink
Merge pull request #2561 from nextcloud/fix/2560/new-task-focus
Browse files Browse the repository at this point in the history
fix: keep input focused for new task
  • Loading branch information
raimund-schluessler committed May 4, 2024
2 parents ffcbae7 + d39c0eb commit e96debb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/components/HeaderBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ export default {
...this.getAdditionalTaskProperties(),
}
const task = await this.createTask(data)
this.openNewTask(task)
await this.openNewTask(task)
this.newTaskName = ''
this.$refs.input.$refs.inputField.$refs.input.focus()
},
getAdditionalTaskProperties() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/TaskBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ export default {
related: this.task.uid,
...this.getAdditionalTaskProperties(),
})
this.openNewTask(task)
await this.openNewTask(task)
this.newTaskName = ''
// Focus the input field again, in case we clicked on the trailing-icon-button
this.$refs.input.$refs.inputField.$refs.input.focus()
Expand Down
8 changes: 4 additions & 4 deletions src/mixins/openNewTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@

export default {
methods: {
openNewTask(task) {
async openNewTask(task) {
// Only open the details view if there is enough space or if it is already open.
if (this.$route.params !== undefined && (document.documentElement.clientWidth >= 768 || this.$route.params.taskId !== undefined)) {
// Open the details view for the new task
const calendarId = this.$route.params.calendarId
const collectionId = this.$route.params.collectionId
if (calendarId) {
this.$router.push({ name: 'calendarsTask', params: { calendarId, taskId: task.uri } })
await this.$router.push({ name: 'calendarsTask', params: { calendarId, taskId: task.uri } })
} else if (collectionId) {
if (collectionId === 'week') {
this.$router.push({
await this.$router.push({
name: 'collectionsParamTask',
params: { collectionId, taskId: task.uri, collectionParam: '0' },
})
} else {
this.$router.push({ name: 'collectionsTask', params: { collectionId, taskId: task.uri } })
await this.$router.push({ name: 'collectionsTask', params: { collectionId, taskId: task.uri } })
}
}
}
Expand Down

0 comments on commit e96debb

Please sign in to comment.