Skip to content

Commit

Permalink
Merge pull request #3 from TappNetwork/fix_empty_state
Browse files Browse the repository at this point in the history
Fix empty state on google autocomplete select
  • Loading branch information
andreia authored Jul 25, 2024
2 parents 2549b77 + a530db5 commit 3fe7118
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Forms/Components/GoogleAutocomplete.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Filament\Forms;
use Filament\Forms\Components\Component;
use Filament\Forms\Components\Concerns;
use Filament\Forms\Get;
use Filament\Forms\Set;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Blade;
Expand Down Expand Up @@ -89,7 +88,15 @@ public function getChildComponents(): array

return [];
})
->afterStateUpdated(function (string $state, Get $get, Set $set, Component $component) {
->afterStateUpdated(function (?string $state, Set $set) {
if ($state === null) {
foreach ($this->getWithFields() as $field) {
$set($field->getName(), null);
}

return;
}

$data = $this->getPlace($state);

$googleFields = $this->getFormattedApiResults($data);
Expand Down

0 comments on commit 3fe7118

Please sign in to comment.