Skip to content

Commit 20ee1f4

Browse files
authored
Merge pull request #25 from OpenKnots/okcode/fix-remove-project-placement
Remove project-specific preview link handling
2 parents b4e74e3 + ea38fb9 commit 20ee1f4

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

apps/web/src/wsNativeApi.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ describe("wsNativeApi", () => {
391391
});
392392
});
393393

394-
it("forwards context menu metadata to desktop bridge", async () => {
394+
it("forwards context menu items to desktop bridge without position", async () => {
395395
const showContextMenu = vi.fn().mockResolvedValue("delete");
396396
Object.defineProperty(getWindowForTest(), "desktopBridge", {
397397
configurable: true,
@@ -411,13 +411,13 @@ describe("wsNativeApi", () => {
411411
{ x: 200, y: 300 },
412412
);
413413

414-
expect(showContextMenu).toHaveBeenCalledWith(
415-
[
416-
{ id: "rename", label: "Rename thread" },
417-
{ id: "delete", label: "Delete", destructive: true },
418-
],
419-
{ x: 200, y: 300 },
420-
);
414+
// Position is intentionally not forwarded to the desktop bridge;
415+
// Electron's Menu.popup() uses the current mouse cursor position
416+
// which avoids coordinate-space mismatches.
417+
expect(showContextMenu).toHaveBeenCalledWith([
418+
{ id: "rename", label: "Rename thread" },
419+
{ id: "delete", label: "Delete", destructive: true },
420+
]);
421421
});
422422

423423
it("uses fallback context menu when desktop bridge is unavailable", async () => {

apps/web/src/wsNativeApi.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,13 @@ export function createWsNativeApi(): NativeApi {
180180
position?: { x: number; y: number },
181181
): Promise<T | null> => {
182182
if (window.desktopBridge) {
183-
return window.desktopBridge.showContextMenu(items, position) as Promise<T | null>;
183+
// Don't pass explicit coordinates to the native Electron menu.
184+
// Let Menu.popup() use the current mouse cursor position, which
185+
// Electron resolves correctly regardless of title-bar style or
186+
// display scaling. Passing CSS clientX/clientY can mis-position
187+
// the menu when the sidebar content is scrolled or when the
188+
// window uses titleBarStyle "hiddenInset".
189+
return window.desktopBridge.showContextMenu(items) as Promise<T | null>;
184190
}
185191
return showContextMenuFallback(items, position);
186192
},

0 commit comments

Comments
 (0)