Skip to content

Commit

Permalink
product tour id refactor and nested element detection
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaB01 committed Oct 4, 2024
1 parent 4558906 commit 329c505
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 8 deletions.
Binary file modified .DS_Store
Binary file not shown.
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.

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.3",
"version": "14.0.4",
"main": "build/cjs/index.js",
"module": "build/esm/index.mjs",
"exports": {
Expand Down
1 change: 1 addition & 0 deletions published/14.0.4/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.

8 changes: 6 additions & 2 deletions src/GleapProductTours.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,12 @@ export default class GleapProductTours {
const element = gleapTourObj.getActiveElement();

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

if (!isInsideElement) {
// Ignore clicks outside of the actual element.
return;
}
}

if ((element && element.tagName === 'INPUT') || step.mode === "INPUT" || evnt?.target?.id.includes("tooltip-svg")) {
Expand Down
14 changes: 12 additions & 2 deletions src/GleapTours.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,18 @@ const GleapTours = function () {
}
function highlight(step, attemptTime = 2000) {
const { element } = step;
let elemObj = typeof element === "string" ? document.querySelector(element) : element;

let elemObj = element;
if (typeof elemObj === "string") {
try {
elemObj = document.querySelector(element);
} catch (error) {
// This will escape colons within IDs but not affect pseudo-classes or other valid uses of colons
let refactoredElement = element.replace(/(#[^#\s]+)/g, function(match) {
return match.replace(/:/g, '\\:');
});
elemObj = document.querySelector(refactoredElement);
}
}
if (element && !elemObj && attemptTime >= 0) {
setTimeout(() => {
hidePopover();
Expand Down

0 comments on commit 329c505

Please sign in to comment.