From 89be1df266e941549dec092765479e4d161d2672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Gl=C3=BCck?= Date: Fri, 22 Aug 2025 17:21:12 +0200 Subject: [PATCH 1/2] Add possibility to prevent navigation away from current domain or page --- src/Facades/Window.php | 2 ++ src/Windows/Window.php | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/Facades/Window.php b/src/Facades/Window.php index 1f4aba8..d23db98 100644 --- a/src/Facades/Window.php +++ b/src/Facades/Window.php @@ -18,6 +18,8 @@ * @method static void maximize($id = null) * @method static void minimize($id = null) * @method static void zoomFactor(float $zoomFactor = 1.0) + * @method static void preventLeaveDomain(bool $preventLeaveDomain = true) + * @method static void preventLeavePage(bool $preventLeavePage = true): self */ class Window extends Facade { diff --git a/src/Windows/Window.php b/src/Windows/Window.php index 245ae0b..fef6c9c 100644 --- a/src/Windows/Window.php +++ b/src/Windows/Window.php @@ -70,6 +70,10 @@ class Window protected float $zoomFactor = 1.0; + protected bool $preventLeaveDomain = false; + + protected bool $preventLeavePage = false; + public function __construct(string $id) { $this->id = $id; @@ -342,6 +346,20 @@ public function zoomFactor(float $zoomFactor = 1.0): self return $this; } + public function preventLeaveDomain(bool $preventLeaveDomain = true): self + { + $this->preventLeaveDomain = $preventLeaveDomain; + + return $this; + } + + public function preventLeavePage(bool $preventLeavePage = true): self + { + $this->preventLeavePage = $preventLeavePage; + + return $this; + } + public function toArray() { return [ @@ -381,6 +399,8 @@ public function toArray() 'transparent' => $this->transparent, 'webPreferences' => $this->webPreferences, 'zoomFactor' => $this->zoomFactor, + 'preventLeaveDomain' => $this->preventLeaveDomain, + 'preventLeavePage' => $this->preventLeavePage, ]; } From 4ab1190bd168dcaa130dd83944429a3ff888a967 Mon Sep 17 00:00:00 2001 From: Willem Leuverink Date: Tue, 2 Sep 2025 12:39:24 +0200 Subject: [PATCH 2/2] add missing return after merge conflict --- src/Windows/Window.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Windows/Window.php b/src/Windows/Window.php index 6ddbe1c..a35fb26 100644 --- a/src/Windows/Window.php +++ b/src/Windows/Window.php @@ -359,6 +359,7 @@ public function preventLeavePage(bool $preventLeavePage = true): self { $this->preventLeavePage = $preventLeavePage; + return $this; } public function suppressNewWindows(): self