Skip to content

Commit c45a5dc

Browse files
committed
fix(desktop): keep preview picking active across subframe navigation
1 parent c8f77e0 commit c45a5dc

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎apps/desktop/src/preview/Manager.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3167,7 +3167,10 @@ describe("PreviewManager", () => {
31673167
listeners.set(event, listener);
31683168
}),
31693169
once: vi.fn((event: string, listener: (...args: unknown[]) => void) => {
3170-
listeners.set(event, listener);
3170+
listeners.set(event, (...args) => {
3171+
listeners.delete(event);
3172+
listener(...args);
3173+
});
31713174
}),
31723175
off: vi.fn(),
31733176
ipc: { on: vi.fn(), off: vi.fn(), removeListener: vi.fn() },
@@ -3193,6 +3196,8 @@ describe("PreviewManager", () => {
31933196
expect(pick.pollUnsafe()).toBeUndefined();
31943197

31953198
listeners.get("did-start-navigation")?.({}, "https://example.com/next", false, true);
3199+
yield* Effect.yieldNow;
3200+
expect(pick.pollUnsafe()).toBeDefined();
31963201
expect(yield* Fiber.join(pick)).toBeNull();
31973202
}),
31983203
),

‎apps/desktop/src/preview/Manager.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2529,7 +2529,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
25292529
yield* attempt({ operation: "pickElement.register", tabId, webContentsId: wc.id }, () => {
25302530
wc.ipc.on(ELEMENT_PICKED_CHANNEL, onMessage);
25312531
wc.once("destroyed", onDestroyed);
2532-
wc.once("did-start-navigation", onNavigated);
2532+
wc.on("did-start-navigation", onNavigated);
25332533
if (!wc.isFocused()) wc.focus();
25342534
wc.send(START_PICK_CHANNEL, annotationTheme);
25352535
});

0 commit comments

Comments
 (0)