mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
fix(files): cancel renaming on enter if no file name changes
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
This commit is contained in:
parent
5af0d137e7
commit
232651774e
2 changed files with 43 additions and 0 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue