Skip to content

Commit

Permalink
tour click prevent when outside and type is CLICK
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaB01 committed Sep 13, 2024
1 parent 8bf001d commit e54c3e5
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build/cjs/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/esm/index.mjs

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ <h2 class="sub-headline">
<div class="header-container-image">
<img class="head-image" src="./pexels-niklas-jeromin-12734294.jpg" />
</div>
<input type="button" value="Start Tour" placeholder="helloo"/>
<input type="text" id="userInput" placeholder="Enter your name">
<button onclick="greetUser()">Submit</button>
<div class="content" id="haha">
<div class="skeleton-text"></div>
<div class="skeleton-text"></div>
Expand All @@ -268,6 +271,17 @@ <h2 class="sub-headline">
<div class="skeleton-text"></div>
<div class="skeleton-text"></div>
</div>

<script>
function greetUser() {
var name = document.getElementById("userInput").value;
if (name) {
alert("Hello, " + name + "! Welcome to Off-Grid-it-Haus.");
} else {
alert("Please enter your name.");
}
}
</script>
</body>

</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gleap",
"version": "14.0.0",
"version": "14.0.1",
"main": "build/cjs/index.js",
"module": "build/esm/index.mjs",
"exports": {
Expand Down
1 change: 1 addition & 0 deletions published/14.0.1/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion published/latest/index.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/GleapProductTours.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default class GleapProductTours {

var driverStep = {
disableActiveInteraction: disableInteraction,
mode: step.mode,
popover: {
description: message,
popoverClass: `gleap-tour-popover-${step.type} ${!hasSender && 'gleap-tour-popover-no-sender'} ${config.allowClose && 'gleap-tour-popover-can-close'}`,
Expand Down Expand Up @@ -104,6 +105,11 @@ export default class GleapProductTours {
const step = steps[stepIndex];
const element = gleapTourObj.getActiveElement();

if (step?.mode === "CLICK" && evnt?.target !== element) {
// Ignore clicks outside of the actual element.
return;
}

if ((element && element.tagName === 'INPUT') || step.mode === "INPUT" || evnt?.target?.id.includes("tooltip-svg")) {
// Prevent.
} else {
Expand Down
8 changes: 8 additions & 0 deletions src/GleapTours.js
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,10 @@ const GleapTours = function () {
const activeIndex = getState("activeIndex");
const activeStep = getState("__activeStep");
const activeElement = getState("__activeElement");

if (activeStep.mode === "CLICK") {
return;
}
if (typeof activeIndex === "undefined" || typeof activeStep === "undefined") {
return;
}
Expand All @@ -989,6 +993,10 @@ const GleapTours = function () {
const activeIndex = getState("activeIndex");
const activeStep = getState("__activeStep");
const activeElement = getState("__activeElement");

if (activeStep.mode === "CLICK") {
return;
}
if (typeof activeIndex === "undefined" || typeof activeStep === "undefined") {
return;
}
Expand Down

0 comments on commit e54c3e5

Please sign in to comment.