fix(tree): defend against stray null values that may occur when multi… (#6821)

This commit is contained in:
Elian Doran 2025-08-30 14:04:02 +03:00 committed by GitHub
commit 864ac1a270
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -133,6 +133,9 @@ function sortNotes(parentNoteId: string, customSortBy: string = "title", reverse
const topBEl = fetchValue(b, "top");
if (topAEl !== topBEl) {
if (topAEl === null) return 1;
if (topBEl === null) return -1;
// since "top" should not be reversible, we'll reverse it once more to nullify this effect
return compare(topAEl, topBEl) * (reverse ? -1 : 1);
}
@ -141,6 +144,9 @@ function sortNotes(parentNoteId: string, customSortBy: string = "title", reverse
const bottomBEl = fetchValue(b, "bottom");
if (bottomAEl !== bottomBEl) {
if (bottomAEl === null) return -1;
if (bottomBEl === null) return 1;
// since "bottom" should not be reversible, we'll reverse it once more to nullify this effect
return compare(bottomBEl, bottomAEl) * (reverse ? -1 : 1);
}