aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2024-04-30 14:16:53 +0200
committerAndy Scherzinger <info@andy-scherzinger.de>2024-05-23 23:48:27 +0200
commita1cdcb832a210df6a4b7690d03f19c5fea4e4ad2 (patch)
tree79b50df7374fdbcf845f5d4e9c3ecaf00a2bd60f
parentb127e020ec7edb4ae2bde89e3eaea13bd081f494 (diff)
downloadnextcloud-server-a1cdcb832a210df6a4b7690d03f19c5fea4e4ad2.tar.gz
nextcloud-server-a1cdcb832a210df6a4b7690d03f19c5fea4e4ad2.zip
fix: Return a file element even if the rendered list does not contained one
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r--apps/files/js/filelist.js14
-rw-r--r--apps/files/tests/js/filelistSpec.js4
2 files changed, 14 insertions, 4 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 55608ada266..4e798003df4 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -1357,8 +1357,18 @@
* @return {Object} jQuery object of the matching row
*/
findFileEl: function(fileName){
- // use filterAttr to avoid escaping issues
- return this.$fileList.find('tr').filterAttr('data-file', fileName);
+ var fileRow = this.$fileList.find('tr').filterAttr('data-file', fileName);
+ if (fileRow.length) {
+ return fileRow;
+ }
+
+ // The row we try to get might not have been rendered due to pagination,
+ // so in case we find the file in the file list return the rendered row instead
+ var fileData = this.files.find(function (el){
+ return el.name === fileName;
+ });
+
+ return fileData ? this._renderRow(fileData, {updateSummary: false, silent: true}) : fileRow;
},
/**
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index 3d80591fd14..252956f9649 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -825,7 +825,7 @@ describe('OCA.Files.FileList tests', function() {
// element is renamed before the request finishes
$tr = fileList.findFileEl('Tu_after_three.txt');
expect($tr.length).toEqual(1);
- expect(fileList.findFileEl('One.txt').length).toEqual(0);
+ expect($('.files-fileList tr').find('[data-name="One.txt"]').length).toEqual(0);
// file actions are hidden
expect($tr.hasClass('busy')).toEqual(true);
@@ -1426,7 +1426,7 @@ describe('OCA.Files.FileList tests', function() {
name: 'File with index 28b.txt'
});
expect($('.files-fileList tr').length).toEqual(20);
- expect(fileList.findFileEl('File with index 28b.txt').length).toEqual(0);
+ expect($('.files-fileList tr').find('[data-name="File with index 28b.txt"]').length).toEqual(0);
fileList._nextPage(true);
expect($('.files-fileList tr').length).toEqual(40);
expect(fileList.findFileEl('File with index 28b.txt').index()).toEqual(29);