Skip to content

Commit 84b3d6d

Browse files
authored
fix(tree): fix failure to auto-activate hoisted note (#7782)
2 parents 25a27c9 + 24820b9 commit 84b3d6d

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

apps/client/src/services/tree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async function resolveNotePathToSegments(notePath: string, hoistedNoteId = "root
8989

9090
effectivePathSegments.reverse();
9191

92-
if (effectivePathSegments.includes(hoistedNoteId)) {
92+
if (effectivePathSegments.includes(hoistedNoteId) && effectivePathSegments.includes('root')) {
9393
return effectivePathSegments;
9494
} else {
9595
const noteId = getNoteIdFromUrl(notePath);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { test, expect } from "@playwright/test";
2+
import App from "../support/app";
3+
4+
const OPTIONS_TITLE = "Options";
5+
const NOTE_TITLE = "Tree Operations"
6+
7+
test("Hoist note remains expanded when opening Options and clicking child note", async ({ page, context }) => {
8+
const app = new App(page, context);
9+
await app.goto();
10+
await app.closeAllTabs();
11+
12+
await app.goToSettings();
13+
14+
// Activate it when opening Options
15+
await expect(app.noteTreeActiveNote).toContainText(OPTIONS_TITLE);
16+
17+
// Clicking a hoist’s child note does not collapse the hoist note
18+
await app.clickNoteOnNoteTreeByTitle("Appearance");
19+
const node = app.page.locator(".fancytree-node.fancytree-submatch:has(.bx-cog)");
20+
await expect(node).toHaveClass(/fancytree-expanded/);
21+
});
22+
23+
test("Activate it when hoisting a note", async ({ page, context }) => {
24+
const app = new App(page, context);
25+
await app.goto();
26+
await app.closeAllTabs();
27+
28+
const treeNode = app.noteTree.getByText(NOTE_TITLE);
29+
await treeNode.click({ button: "right" });
30+
const hoistMenuItem = page.locator(
31+
'#context-menu-container .dropdown-item span',
32+
{ hasText: "Hoist note" }
33+
);
34+
await hoistMenuItem.click();
35+
await expect(app.noteTreeActiveNote).toContainText(NOTE_TITLE);
36+
await app.page.locator(".unhoist-button").click();
37+
await expect(app.noteTreeActiveNote).toContainText(NOTE_TITLE);
38+
});

0 commit comments

Comments
 (0)