mirror of
https://github.com/nextcloud/server.git
synced 2024-08-06 15:06:39 +02:00
Skip hidden files when counting visible files in list (#26522)
The file list UI logic that renders the next page doesn't properly exclude hidden files when not shown. This fix makes sure that only rows that are actually visible are counted when rendering a page, this makes sure that the page will always have enough elements displayed.
This commit is contained in:
parent
cebb689925
commit
1141fcc9ac
@ -923,7 +923,8 @@
|
||||
tr,
|
||||
fileData,
|
||||
newTrs = [],
|
||||
isAllSelected = this.isAllSelected();
|
||||
isAllSelected = this.isAllSelected(),
|
||||
showHidden = this._filesConfig.get('showhidden');
|
||||
|
||||
if (index >= this.files.length) {
|
||||
return false;
|
||||
@ -947,7 +948,10 @@
|
||||
}
|
||||
newTrs.push(tr);
|
||||
index++;
|
||||
count--;
|
||||
// only count visible rows
|
||||
if (showHidden || !tr.hasClass('hidden-file')) {
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
// trigger event for newly added rows
|
||||
|
@ -1120,6 +1120,34 @@ describe('OCA.Files.FileList tests', function() {
|
||||
expect(fileList.files.length).toEqual(65);
|
||||
expect($('#fileList tr').length).toEqual(20);
|
||||
});
|
||||
it('renders the full first page despite hidden rows', function() {
|
||||
filesConfig.set('showhidden', false);
|
||||
var files = _.map(generateFiles(0, 23), function(data) {
|
||||
return _.extend(data, {
|
||||
name: '.' + data.name
|
||||
});
|
||||
});
|
||||
// only hidden files + one visible
|
||||
files.push(testFiles[0]);
|
||||
fileList.setFiles(files);
|
||||
expect(fileList.files.length).toEqual(25);
|
||||
// render 24 hidden elements + the visible one
|
||||
expect($('#fileList tr').length).toEqual(25);
|
||||
});
|
||||
it('renders the full first page despite hidden rows', function() {
|
||||
filesConfig.set('showhidden', true);
|
||||
var files = _.map(generateFiles(0, 23), function(data) {
|
||||
return _.extend(data, {
|
||||
name: '.' + data.name
|
||||
});
|
||||
});
|
||||
// only hidden files + one visible
|
||||
files.push(testFiles[0]);
|
||||
fileList.setFiles(files);
|
||||
expect(fileList.files.length).toEqual(25);
|
||||
// render 20 first hidden elements as visible
|
||||
expect($('#fileList tr').length).toEqual(20);
|
||||
});
|
||||
it('renders the second page when scrolling down (trigger nextPage)', function() {
|
||||
// TODO: can't simulate scrolling here, so calling nextPage directly
|
||||
fileList._nextPage(true);
|
||||
|
Loading…
Reference in New Issue
Block a user