1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

Desktop: Fixes #10077: Special characters in notebooks and tags are not sorted alphabetically (#10085)

Co-authored-by: Martin Dörfelt <martin.d@andix.de>
Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
This commit is contained in:
cagnusmarlsen
2024-03-20 16:47:46 +05:30
committed by GitHub
parent ea29cf4e13
commit e9ebd845b9
7 changed files with 70 additions and 12 deletions

View File

@ -2,6 +2,7 @@ import Folder from '../../models/Folder';
import BaseModel from '../../BaseModel';
import { FolderEntity, TagEntity } from '../../services/database/types';
import { getDisplayParentId, getTrashFolderId } from '../../services/trash';
import { getCollator } from '../../models/utils/getCollator';
interface Props {
folders: FolderEntity[];
@ -72,6 +73,7 @@ export const renderFolders = (props: Props, renderItem: RenderFolderItem) => {
export const renderTags = (props: Props, renderItem: RenderTagItem) => {
const tags = props.tags.slice();
const collator = getCollator();
tags.sort((a, b) => {
// It seems title can sometimes be undefined (perhaps when syncing
// and before tag has been decrypted?). It would be best to find
@ -83,7 +85,7 @@ export const renderTags = (props: Props, renderItem: RenderTagItem) => {
// Note: while newly created tags are normalized and lowercase
// imported tags might be any case, so we need to do case-insensitive
// sort.
return a.title.toLowerCase() < b.title.toLowerCase() ? -1 : +1;
return collator.compare(a.title, b.title);
});
const tagItems = [];
const order: string[] = [];