From e43c08142a34157d60e705e431bdfa86e9e04670 Mon Sep 17 00:00:00 2001 From: Mahesh Perera Date: Mon, 20 Jan 2025 05:55:17 +0530 Subject: [PATCH] Added 'disableActiveInteraction' per step. (#534) --- docs/src/content/guides/configuration.mdx | 4 ++++ src/driver.ts | 1 + src/highlight.ts | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/src/content/guides/configuration.mdx b/docs/src/content/guides/configuration.mdx index d333265..b598e40 100644 --- a/docs/src/content/guides/configuration.mdx +++ b/docs/src/content/guides/configuration.mdx @@ -42,6 +42,7 @@ type Config = { allowKeyboardControl?: boolean; // Whether to disable interaction with the highlighted element. (default: false) + // Can be configured at the step level as well disableActiveInteraction?: boolean; // If you want to add custom class to the popover @@ -197,6 +198,9 @@ type DriveStep = { // Look at the Popover Configuration section popover?: Popover; + // Whether to disable interaction with the highlighted element. (default: false) + disableActiveInteraction?: boolean; + // Callback when the current step is deselected, // about to be highlighted or highlighted. // Each callback receives the following parameters: diff --git a/src/driver.ts b/src/driver.ts index aefdb2a..8184fc2 100644 --- a/src/driver.ts +++ b/src/driver.ts @@ -13,6 +13,7 @@ export type DriveStep = { onHighlighted?: DriverHook; onDeselected?: DriverHook; popover?: Popover; + disableActiveInteraction?: boolean; }; export function driver(options: Config = {}) { diff --git a/src/highlight.ts b/src/highlight.ts index 961a26a..ec55303 100644 --- a/src/highlight.ts +++ b/src/highlight.ts @@ -157,7 +157,7 @@ function transferHighlight(toElement: Element, toStep: DriveStep) { fromElement.removeAttribute("aria-expanded"); fromElement.removeAttribute("aria-controls"); - const disableActiveInteraction = getConfig("disableActiveInteraction"); + const disableActiveInteraction = toStep.disableActiveInteraction ?? getConfig("disableActiveInteraction"); if (disableActiveInteraction) { toElement.classList.add("driver-no-interaction"); }