Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Focus first input when creating a new table/row/column/view #925

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cypress/e2e/column-selection.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('Test column ' + columnTitle, () => {
cy.get('button').contains('Create row').click()
cy.get('.modal__content h2').contains('Create row').should('be.visible')
cy.get('.modal__content .title').contains(columnTitle).should('be.visible')
cy.get('.modal__content .title').click()
cy.get('.modal__content .select span[title="second option"]').should('be.visible')
cy.get('button').contains('Save').click()
cy.get('.custom-table table tr td div').contains('second option').should('be.visible')
Expand Down
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
Loading