Skip to content

Commit 133bda6

Browse files
committed
improved urlHandler
1 parent 1424119 commit 133bda6

File tree

8 files changed

+23
-9
lines changed

8 files changed

+23
-9
lines changed

build/cjs/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/esm/index.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

demo/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const Gleap = window.Gleap;
22

33
Gleap.setFrameUrl("http://0.0.0.0:3001");
4-
Gleap.setApiUrl("http://0.0.0.0:9000");
5-
Gleap.setWSApiUrl("ws://0.0.0.0:9000");
4+
// Gleap.setApiUrl("http://0.0.0.0:9000");
5+
// Gleap.setWSApiUrl("ws://0.0.0.0:9000");
66

7-
Gleap.initialize("EylYN1UChqJkT5wJHu3bA8hswd9xOWJ6");
7+
Gleap.initialize("<API_KEY>");

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gleap",
3-
"version": "13.9.1",
3+
"version": "13.9.2",
44
"main": "build/cjs/index.js",
55
"module": "build/esm/index.mjs",
66
"exports": {

published/13.9.1/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

published/13.9.2/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

published/latest/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/GleapFrameManager.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,20 @@ export default class GleapFrameManager {
3636
urlHandler = function (url, newTab) {
3737
if (url && url.length > 0) {
3838
if (newTab) {
39-
window.open(url, "_blank").focus();
39+
const newWindow = window.open(url, "_blank");
40+
41+
// Check if the new window was successfully created and not blocked
42+
if (
43+
!newWindow ||
44+
newWindow.closed ||
45+
typeof newWindow.closed === "undefined"
46+
) {
47+
// If the new window was blocked, navigate in the same tab instead
48+
window.location.href = url;
49+
} else {
50+
// If the new window was created successfully, bring it into focus
51+
newWindow.focus();
52+
}
4053
} else {
4154
window.location.href = url;
4255
}

0 commit comments

Comments
 (0)