Skip to content

Commit

Permalink
Merge pull request #49693 from nextcloud/fix/files-rename-esc
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Dec 10, 2024
2 parents 4da101e + 1ccce41 commit 70346e0
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
4 changes: 4 additions & 0 deletions apps/files/src/components/FileEntry/FileEntryName.vue
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ export default defineComponent({
}

const oldName = this.source.basename
if (newName === oldName) {
this.stopRenaming()
return
}

try {
const status = await this.renamingStore.rename()
Expand Down
39 changes: 39 additions & 0 deletions cypress/e2e/files/files-renaming.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,43 @@ describe('files: Rename nodes', { testIsolation: true }, () => {
.findByRole('textbox', { name: 'Filename' })
.should('not.exist')
})

it('cancel renaming on esc press', () => {
// All are visible by default
getRowForFile('file.txt').should('be.visible')

triggerActionForFile('file.txt', 'rename')

getRowForFile('file.txt')
.findByRole('textbox', { name: 'Filename' })
.should('be.visible')
.type('{selectAll}other.txt')
.should(haveValidity(''))
.type('{esc}')

// See it is not renamed
getRowForFile('other.txt').should('not.exist')
getRowForFile('file.txt')
.should('be.visible')
.find('input[type="text"]')
.should('not.exist')
})

it('cancel on enter if no new name is entered', () => {
// All are visible by default
getRowForFile('file.txt').should('be.visible')

triggerActionForFile('file.txt', 'rename')

getRowForFile('file.txt')
.findByRole('textbox', { name: 'Filename' })
.should('be.visible')
.type('{enter}')

// See it is not renamed
getRowForFile('file.txt')
.should('be.visible')
.find('input[type="text"]')
.should('not.exist')
})
})
4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

0 comments on commit 70346e0

Please sign in to comment.