Skip to content
Merged
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
7 changes: 6 additions & 1 deletion packages/g6/src/plugins/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,12 @@ export class Tooltip extends BasePlugin<TooltipOptions> {
const { getContent, title } = this.options;
const items: ElementDatum[] = this.getElementData(id, targetType as ElementType);

if (!this.tooltipElement || !this.isEnable(event, items)) return;
if (!this.tooltipElement) return;
// if shown, when is not enable, hide
if (!this.isEnable(event, items)) {
this.hide(event);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Calling this.hide(event) here can cause a runtime error. The event object might not have a client property, for example when show() is called via showById(). The hide() method unconditionally destructures event.client, which will throw an exception if client is undefined.

To fix this, we can conditionally pass the event to hide() only when event.client exists. If it doesn't, calling hide() with undefined will trigger the safe path within the hide method that does not access the client property.

Suggested change
this.hide(event);
this.hide(event.client ? event : undefined);

return;
}

let tooltipContent: { [key: string]: unknown } = {};
if (getContent) {
Expand Down
Loading