Skip to content

Commit 54afe0b

Browse files
committed
Do NOT assume all files are selected if the first checkbox is
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
1 parent 4fd2cbe commit 54afe0b

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

apps/files/js/filelist.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,16 @@
897897
* Event handler for when selecting/deselecting all files
898898
*/
899899
_onClickSelectAll: function(e) {
900-
var checked = $(e.target).prop('checked');
900+
var hiddenFiles = this.$fileList.find('tr.hidden');
901+
var checked = e.target.checked;
902+
903+
if (hiddenFiles.length > 0) {
904+
// set indeterminate alongside checked
905+
e.target.indeterminate = checked;
906+
} else {
907+
e.target.indeterminate = false
908+
}
909+
901910
// Select only visible checkboxes to filter out unmatched file in search
902911
this.$fileList.find('td.selection > .selectCheckBox:visible').prop('checked', checked)
903912
.closest('tr').toggleClass('selected', checked);
@@ -907,7 +916,7 @@
907916
// a search will automatically hide the unwanted rows
908917
// let's only select the matches
909918
var fileData = this.files[i];
910-
var fileRow = this.$fileList.find('[data-id=' + fileData.id + ']');
919+
var fileRow = this.$fileList.find('tr[data-id=' + fileData.id + ']');
911920
// do not select already selected ones
912921
if (!fileRow.hasClass('hidden') && _.isUndefined(this._selectedFiles[fileData.id])) {
913922
this._selectedFiles[fileData.id] = fileData;
@@ -917,7 +926,6 @@
917926
} else {
918927
// if we have some hidden row, then we're in a search
919928
// Let's only deselect the visible ones
920-
var hiddenFiles = this.$fileList.find('tr.hidden');
921929
if (hiddenFiles.length > 0) {
922930
var visibleFiles = this.$fileList.find('tr:not(.hidden)');
923931
var self = this;
@@ -3260,11 +3268,15 @@
32603268
},
32613269

32623270
/**
3263-
* Returns whether all files are selected
3264-
* @return true if all files are selected, false otherwise
3271+
* Are all files selected?
3272+
*
3273+
* @returns {Boolean} all files are selected
32653274
*/
32663275
isAllSelected: function() {
3267-
return this.$el.find('.select-all').prop('checked');
3276+
var checkbox = this.$el.find('.select-all')
3277+
var checked = checkbox.prop('checked')
3278+
var indeterminate = checkbox.prop('indeterminate')
3279+
return checked && !indeterminate;
32683280
},
32693281

32703282
/**

0 commit comments

Comments
 (0)