From 70da7a4b37059ec5838ff4102e10ef9ba03dd55d Mon Sep 17 00:00:00 2001 From: Nikita Rokotyan Date: Thu, 25 Jan 2024 13:17:39 -0800 Subject: [PATCH 1/3] Component | Tooltip: Allowing `triggers` to be undefined #0 --- packages/ts/src/components/tooltip/config.ts | 2 +- packages/ts/src/components/tooltip/index.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/ts/src/components/tooltip/config.ts b/packages/ts/src/components/tooltip/config.ts index 3ff80ebc7..260ffd4d9 100644 --- a/packages/ts/src/components/tooltip/config.ts +++ b/packages/ts/src/components/tooltip/config.ts @@ -33,7 +33,7 @@ export interface TooltipConfigInterface { * ``` */ triggers?: { - [selector: string]: (data: any, i: number, elements: (HTMLElement | SVGElement)[]) => string | HTMLElement | undefined | null; + [selector: string]: ((data: any, i: number, elements: (HTMLElement | SVGElement)[]) => string | HTMLElement | undefined | null) | undefined | null; }; /** Custom DOM attributes for the tooltip. Useful when you need to refer to a specific tooltip instance * by using a CSS selector. Attributes configuration object has the following structure: diff --git a/packages/ts/src/components/tooltip/index.ts b/packages/ts/src/components/tooltip/index.ts index 74be78ee4..b143cd174 100644 --- a/packages/ts/src/components/tooltip/index.ts +++ b/packages/ts/src/components/tooltip/index.ts @@ -185,6 +185,8 @@ export class Tooltip { // Go through all of the configured triggers for (const className of Object.keys(triggers)) { const template = triggers[className] + if (!template) continue // Skip if the trigger is not configured + const els = selection.selectAll(`.${className}`).nodes() // Go through all of the elements in the event path (from the deepest element upwards) From 18530e9b3426907a39c64dc881767ac3fb4d3fd8 Mon Sep 17 00:00:00 2001 From: Nikita Rokotyan Date: Thu, 25 Jan 2024 13:21:32 -0800 Subject: [PATCH 2/3] Component | Tooltip: Don't change `body` position style If the container is `body`, don't change its style because it can have unwanted side effects on the page #0 --- packages/ts/src/components/tooltip/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ts/src/components/tooltip/index.ts b/packages/ts/src/components/tooltip/index.ts index b143cd174..eb43d86ef 100644 --- a/packages/ts/src/components/tooltip/index.ts +++ b/packages/ts/src/components/tooltip/index.ts @@ -163,7 +163,7 @@ export class Tooltip { private _setContainerPosition (): void { // Tooltip position calculation relies on the parent position // If it's not set (static), we set it to `relative` (not a good practice) - if (getComputedStyle(this._container)?.position === 'static') { + if (this._container !== document.body && getComputedStyle(this._container)?.position === 'static') { this._container.style.position = 'relative' } } From b78d2c671d893b78e5e7405cc4996dcb5c160d67 Mon Sep 17 00:00:00 2001 From: Nikita Rokotyan Date: Thu, 25 Jan 2024 13:21:42 -0800 Subject: [PATCH 3/3] Core | Component | Events: Check if the callback exists before execution #0 --- packages/ts/src/core/component/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ts/src/core/component/index.ts b/packages/ts/src/core/component/index.ts index 63fe0ec31..a254f344c 100644 --- a/packages/ts/src/core/component/index.ts +++ b/packages/ts/src/core/component/index.ts @@ -141,7 +141,7 @@ export class ComponentCore< const els = selection.nodes() const i = els.indexOf(event.currentTarget as SVGGElement | HTMLElement) const eventFunction = events[className][eventType as VisEventType] - return eventFunction(d, event, i, els) + return eventFunction?.(d, event, i, els) }) }) })