Skip to content

Commit

Permalink
chore: Update WithScroll trait to refresh items when clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
francoism90 committed Jul 20, 2024
1 parent 7dcf0de commit 82a9a79
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/Layout/Concerns/WithScroll.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public function mountWithScroll(): void
}
}

public function updatedPage(): void
{
unset($this->items);
}

#[Computed(persist: true)]
public function items(): array
{
Expand All @@ -46,18 +51,11 @@ public function fetch(): void
);
}

public function refresh(): void
{
unset($this->items);

$this->dispatch('$refresh');
}

public function clear(): void
{
$this->reset('models');

$this->refresh();
unset($this->items);

$this->resetPage();
}
Expand All @@ -79,6 +77,6 @@ protected function getScrollLimit(?int $page = null): int
{
$page ??= $this->getPage() ?? 1;

return Number::clamp($page, 1, 32);
return Number::clamp($page, min: 1, max: 32);
}
}

0 comments on commit 82a9a79

Please sign in to comment.