Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't process link mouseover effects when links are hidden. #392

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/LGraphCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5055,6 +5055,7 @@ export class LGraphCanvas {
* @todo Split tooltip from hover, so it can be drawn / eased separately
*/
drawLinkTooltip(ctx: CanvasRenderingContext2D, link: LinkSegment): void {
if (this.links_render_mode === LinkRenderType.HIDDEN_LINK) return
const pos = link._pos
ctx.fillStyle = "black"
ctx.beginPath()
Expand Down
26 changes: 26 additions & 0 deletions test/LGraphCanvas.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { lgTest } from "./lgTest"
import { expect, describe, vi } from "vitest"
import { LGraphCanvas } from "@/LGraphCanvas"
import { LinkRenderType } from "@/types/globalEnums"

describe("Link rendering", () => {
lgTest("should not draw link mouseover effect when links are hidden", () => {
const mockCtx = {
fillText: vi.fn(),
measureText: vi.fn(() => ({ width: 100 })),
} as unknown as CanvasRenderingContext2D

const mockLink = {} as any

const mockCanvas: Partial<LGraphCanvas> = {
links_render_mode: LinkRenderType.HIDDEN_LINK,
} as LGraphCanvas

// Directly call the method that draws link mouseover effects and tooltips
const drawLinkTooltip = LGraphCanvas.prototype.drawLinkTooltip
drawLinkTooltip.call(mockCanvas, mockCtx, mockLink)

// Verify that no text rendering was attempted
expect(mockCtx.fillText).not.toHaveBeenCalled()
})
})
Loading