Skip to content

Commit

Permalink
Merge pull request #1536 from moonshine-software/fix-table-lazy
Browse files Browse the repository at this point in the history
fix: Table lazy
  • Loading branch information
lee-to authored Feb 12, 2025
2 parents c61c69e + 2bc8ec8 commit 9940514
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Laravel/src/Pages/Crud/IndexPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,10 @@ protected function getItemsComponent(iterable $items, Fields $fields): Component
)
->buttons($this->getResource()->getIndexButtons())
->clickAction($this->getResource()->getClickAction())
->when($this->getResource()->isAsync(), static function (TableBuilderContract $table): void {
$table->async()->pushState();
->when($this->getResource()->isAsync(), function (TableBuilderContract $table): void {
$table->async(
url: fn() => $this->getRouter()->getEndpoints()->component(name: $table->getName(), additionally: request()->query())
)->pushState();
})
->when($this->getResource()->isStickyTable(), function (TableBuilderContract $table): void {
$table->sticky();
Expand Down
6 changes: 5 additions & 1 deletion src/UI/resources/js/Request/Sets.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ export function listComponentRequest(component, pushState = false) {
let componentRequestData = new ComponentRequestData()
componentRequestData
.withBeforeHandleResponse(function (data, t) {
const query = originalUrl.slice(originalUrl.indexOf('?') + 1)
let query = originalUrl.slice(originalUrl.indexOf('?') + 1)
const params = new URLSearchParams(query)
params.delete('_component_name')

query = params.toString()

if (pushState) {
history.pushState({}, '', query ? '?' + query : location.pathname)
Expand Down

0 comments on commit 9940514

Please sign in to comment.