Skip to content

Commit

Permalink
fix: [BUG] - Documents: Folders view filter issue if folder title has…
Browse files Browse the repository at this point in the history
… Umlaut - EXO-76165

Prior to this fix, Files starting with accented characters, returned by load more are placed among the items retrieved with the first call. This is because this characters are retrieved at the end of the sorted items from the database but in the front side we apply a natural sorting that ensures that accented characters are placed after their non-accented counterparts.

This commit fix this by splitting the list of items (accented and not eccented) then sort them separately.
  • Loading branch information
mkrout committed Feb 13, 2025
1 parent b532020 commit c185d3c
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,20 @@ export default {
},
customSort: function (items, sortBy, isDesc) {
let sorted = items;
const accentedExp = /[À-ÖØ-öø-ÿ]/;
if (sortBy[1] === 'name') {
const folders = items.filter((item) => item.folder);
const files = items.filter((item) => !item.folder);
const nonAccentedFolders = folders.filter((item) => !accentedExp.test(item.name[0]));
const accentedFolders = folders.filter((item) => accentedExp.test(item.name[0]));
const nonAccentedFiles = files.filter((item) => !accentedExp.test(item.name[0]));
const accentedFiles = files.filter((item) => accentedExp.test(item.name[0]));
const collator = new Intl.Collator(eXo.env.portal.language, {numeric: true, sensitivity: 'base'});
sorted = items.sort((a, b) => {
return (b.folder - a.folder) || collator.compare(a.name, b.name);
});
nonAccentedFolders.sort((a, b) =>collator.compare(a.name, b.name));
accentedFolders.sort((a, b) =>collator.compare(a.name, b.name));
nonAccentedFiles.sort((a, b) =>collator.compare(a.name, b.name));
accentedFiles.sort((a, b) =>collator.compare(a.name, b.name));
sorted = [...nonAccentedFolders,...accentedFolders, ...nonAccentedFiles, ...accentedFiles];
if (isDesc[1]) {
return sorted.reverse();
}
Expand Down

0 comments on commit c185d3c

Please sign in to comment.