Skip to content

Commit

Permalink
fix: Focus first input when creating
Browse files Browse the repository at this point in the history
 a new table/row/column/view

Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliushaertl committed Mar 12, 2024
1 parent 0c782ac commit e56bad7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/modules/modals/CreateColumn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ export default {
combinedType() {
this.reset(false, false)
},
showModal() {
this.$nextTick(() => {
this.$el.querySelector('input')?.focus()
})
},
},
methods: {
snakeToCamel(str) {
Expand Down
7 changes: 7 additions & 0 deletions src/modules/modals/CreateRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ export default {
return mandatoryFieldsEmpty
},
},
watch: {
showModal() {
this.$nextTick(() => {
this.$el.querySelector('input')?.focus()
})
},
},
methods: {
actionCancel() {
this.reset()
Expand Down
4 changes: 3 additions & 1 deletion src/modules/modals/CreateTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
{{ icon }}
</NcButton>
</NcEmojiPicker>
<input v-model="title"
<input ref="titleInput"
v-model="title"
:class="{missing: errorTitle}"
type="text"
:placeholder="t('tables', 'Title of the new table')"
Expand Down Expand Up @@ -100,6 +101,7 @@ export default {
showModal() {
// every time when the modal opens chose a new emoji
this.loadEmoji()
this.$nextTick(() => this.$refs.titleInput.focus())
},
},
beforeMount() {
Expand Down
1 change: 1 addition & 0 deletions src/modules/modals/ViewSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export default {
this.reset()
await this.loadTableColumnsFromBE()
this.open = true
this.$nextTick(() => this.$el.querySelector('input')?.focus())
}
},
open(value) {
Expand Down

0 comments on commit e56bad7

Please sign in to comment.