fix(share): Prevent crashing if candidate note is null (#8164)

This commit is contained in:
Elian Doran
2025-12-29 20:43:12 +02:00
committed by GitHub

View File

@@ -15,13 +15,17 @@
// We are not the first child at this level so previous
// should go to the end of the previous tree
let candidate = children[index - 1];
while (candidate.hasVisibleChildren()) {
const children = candidate.getVisibleChildNotes();
const lastChild = children[children.length - 1];
candidate = lastChild;
while (candidate?.hasVisibleChildren()) {
const visibleChildren = candidate.getVisibleChildNotes();
if (visibleChildren.length === 0) {
break;
}
candidate = visibleChildren[visibleChildren.length - 1];
}
return candidate;
return candidate ?? null;
})();
const nextNote = (() => {