Merge pull request #49693 from nextcloud/fix/files-rename-esc

This commit is contained in:
John Molakvoæ 2024-12-10 11:53:42 +01:00 committed by GitHub
commit 70346e0214
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 46 additions and 3 deletions

View file

@ -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()

View file

@ -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
dist/files-main.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long