Skip to content

Commit 4ccc492

Browse files
committed
Fixes #383 - adds support for disableActiveInteraction option
1 parent c2d9950 commit 4ccc492

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,13 @@ <h2>Usage and Demo</h2>
386386
description: "You can now have popovers without elements as well",
387387
},
388388
},
389+
{
390+
element: '.buttons',
391+
popover: {
392+
title: "Buttons",
393+
description: "Here are some buttons",
394+
},
395+
},
389396
{
390397
element: "#scrollable-area",
391398
popover: {
@@ -457,6 +464,7 @@ <h2>Usage and Demo</h2>
457464
const driverObj = driver({
458465
animate: true,
459466
steps: basicTourSteps,
467+
disableActiveInteraction: true,
460468
showProgress: true,
461469
progressText: "{{current}} of {{total}} done",
462470
onPopoverRender: (popover) => {

src/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export type Config = {
1515
stagePadding?: number;
1616
stageRadius?: number;
1717

18+
disableActiveInteraction?: boolean;
19+
1820
allowKeyboardControl?: boolean;
1921

2022
// Popover specific configuration
@@ -54,6 +56,7 @@ export function configure(config: Config = {}) {
5456
allowClose: true,
5557
overlayOpacity: 0.7,
5658
smoothScroll: false,
59+
disableActiveInteraction: false,
5760
showProgress: false,
5861
stagePadding: 10,
5962
stageRadius: 5,

src/driver.css

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@
8080
transition-duration: 200ms;
8181
}
8282

83-
.driver-popover-close-btn:hover, .driver-popover-close-btn:focus {
83+
.driver-popover-close-btn:hover,
84+
.driver-popover-close-btn:focus {
8485
color: #2d2d2d;
8586
}
8687

@@ -140,7 +141,12 @@
140141
overflow: hidden !important;
141142
}
142143

143-
.driver-popover-footer button:hover, .driver-popover-footer button:focus {
144+
.driver-no-interaction, .driver-no-interaction * {
145+
pointer-events: none !important;
146+
}
147+
148+
.driver-popover-footer button:hover,
149+
.driver-popover-footer button:focus {
144150
background-color: #f7f7f7;
145151
}
146152

src/highlight.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,16 @@ function transferHighlight(toElement: Element, toStep: DriveStep) {
146146
renderPopover(toElement, toStep);
147147
}
148148

149-
fromElement.classList.remove("driver-active-element");
149+
fromElement.classList.remove("driver-active-element", "driver-no-interaction");
150150
fromElement.removeAttribute("aria-haspopup");
151151
fromElement.removeAttribute("aria-expanded");
152152
fromElement.removeAttribute("aria-controls");
153153

154+
const disableActiveInteraction = getConfig("disableActiveInteraction");
155+
if (disableActiveInteraction) {
156+
toElement.classList.add("driver-no-interaction");
157+
}
158+
154159
toElement.classList.add("driver-active-element");
155160
toElement.setAttribute("aria-haspopup", "dialog");
156161
toElement.setAttribute("aria-expanded", "true");
@@ -160,7 +165,7 @@ function transferHighlight(toElement: Element, toStep: DriveStep) {
160165
export function destroyHighlight() {
161166
document.getElementById("driver-dummy-element")?.remove();
162167
document.querySelectorAll(".driver-active-element").forEach(element => {
163-
element.classList.remove("driver-active-element");
168+
element.classList.remove("driver-active-element", "driver-no-interaction");
164169
element.removeAttribute("aria-haspopup");
165170
element.removeAttribute("aria-expanded");
166171
element.removeAttribute("aria-controls");

src/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ export function getFocusableElements(parentEls: Element[] | HTMLElement[]) {
1818

1919
return [...(isParentFocusable ? [parentEl as HTMLElement] : []), ...focusableEls];
2020
})
21-
.filter(el => isElementVisible(el));
21+
.filter(el => {
22+
return getComputedStyle(el).pointerEvents !== "none" && isElementVisible(el);
23+
});
2224
}
2325

2426
export function bringInView(element: Element) {

0 commit comments

Comments
 (0)