From e1637cbe0257606224daf529778c40caf3c47e52 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 26 Oct 2026 18:30:10 +0100 Subject: [PATCH] fix(new-resource): render the resource search binding only on the type step The searchResources() x-data wrapper was outside the type-step @if that renders its script, so a direct load of a later step (for example the PostgreSQL image picker from global search or a reload) threw "searchResources is not defined". Closes #12337 Co-Authored-By: Claude Opus 5.5 --- .../views/livewire/project/new/select.blade.php | 8 ++++---- .../NewResourceSelectServerScopeTest.php | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/resources/views/livewire/project/new/select.blade.php b/resources/views/livewire/project/new/select.blade.php index c1b255f72a..5288bf6eaf 100644 --- a/resources/views/livewire/project/new/select.blade.php +++ b/resources/views/livewire/project/new/select.blade.php @@ -1,6 +1,6 @@
-
- @if ($current_step === 'type') + @if ($current_step === 'type') +
+
+ @endif @if ($current_step === 'servers') diff --git a/tests/Feature/NewResourceSelectServerScopeTest.php b/tests/Feature/NewResourceSelectServerScopeTest.php index c534877e28..a55321e0de 100644 --- a/tests/Feature/NewResourceSelectServerScopeTest.php +++ b/tests/Feature/NewResourceSelectServerScopeTest.php @@ -131,3 +131,20 @@ test('the postgresql shortcut ignores a server that is not in the server list', ->assertSet('server', null) ->assertSet('current_step', 'type'); }); + +test('the postgresql image step does not reference the resource search script it does not render', function () { + Livewire::withQueryParams([ + 'type' => 'postgresql', + 'server_id' => $this->server->id, + 'destination' => $this->defaultDestination->uuid, + ])->test(Select::class) + ->assertSet('current_step', 'select-postgresql-type') + ->assertDontSeeHtml('searchResources'); +}); + +test('the resource type step renders the resource search script with its binding', function () { + Livewire::test(Select::class) + ->assertSet('current_step', 'type') + ->assertSeeHtml('x-data="searchResources()"') + ->assertSeeHtml('function searchResources()'); +});