Skip to content

Commit 91f7f50

Browse files
committed
feat: enhance InspectorHints to better handle Magewire components
1 parent 91b5f60 commit 91f7f50

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

src/Model/TemplateEngine/Decorator/InspectorHints.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,13 @@ public function render(BlockInterface $block, $templateFile, array $dictionary =
8383
return $result;
8484
}
8585

86-
// Do not wrap if content seems to be a Magewire component (to prevent DOM diffing issues)
87-
// Check for common Magewire/Livewire data attributes
88-
if (stripos($result, 'wire:id') !== false ||
89-
stripos($result, 'wire:initial-data') !== false ||
90-
stripos($result, 'x-data="initMagewire') !== false) {
86+
// Do not wrap if content seems to be a Magewire/Livewire component (to prevent DOM diffing issues)
87+
// Check for any wire: attributes or Magewire initialization
88+
if (stripos($result, 'wire:') !== false ||
89+
stripos($result, 'livewire') !== false ||
90+
stripos($result, 'magewire') !== false ||
91+
stripos($result, 'x-data="initMagewire') !== false ||
92+
stripos($result, '@entangle') !== false) {
9193
return $result;
9294
}
9395

src/Model/TemplateEngine/Plugin/InspectorHints.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,18 @@ public function afterCreate(
8181
return $invocationResult;
8282
}
8383

84-
// Additional check for Magewire if not sent as XHR or checkout page
85-
// Check diverse Request URI and Path Info variations to catch all Magewire output
84+
// Disable for Hyva Checkout (Magewire-based) - check both URI and PathInfo
8685
$requestUri = $this->request->getRequestUri();
8786
$pathInfo = $this->request->getPathInfo();
8887

89-
if (($requestUri && stripos($requestUri, 'magewire') !== false) ||
90-
($pathInfo && stripos($pathInfo, 'magewire') !== false)) {
88+
// Block entire /checkout/ route (Hyva Checkout uses Magewire)
89+
if (($requestUri && stripos($requestUri, '/checkout') !== false) ||
90+
($pathInfo && stripos($pathInfo, '/checkout') !== false)) {
9191
return $invocationResult;
9292
}
9393

94-
// Also check regex for partial matches if simple strings fail
95-
if (preg_match('/magewire|livewire/i', (string)$requestUri)) {
94+
// Block any magewire/livewire endpoints
95+
if (preg_match('/\/(magewire|livewire)\//i', (string)$requestUri)) {
9696
return $invocationResult;
9797
}
9898

0 commit comments

Comments
 (0)