binggle's avatar

Multiple paginators on the same page not works

First , sorry for multiple posting.. I know livewire team is too busy.

I used Laravel Framework : 8.64.0 / livewire/livewire : 2.6.7 .

I made video for showing this bug. Please go Check it first.

https://streamable.com/tsg57n

I made simple project which follows https://laravel-livewire.com/docs/2.x/pagination.

I made PostComponent / CommentComponent , and put two component on welcome page together.

in welcome.blade.php

<div class="grid grid-cols-2 gap-1" >
    <div>
        @livewire('post-component')
    </div>
    <div>
        @livewire('comment-component')
    </div>
</div>

PostComponent.php


class PostComponent extends Component
{
    use WithPagination;
    public function render()
    {
        return view('livewire.post-component', [
            'posts'=> Post::paginate(),
        ]);
    }
}

post-component.blade.php

<div>
    <div class="font-bold text-lg"> Post-Component</div>
    <div > page : <span class="text-red-500 ">{{ $page }} </span></div>
    <hr class="h-4 "/>
    @foreach ($posts as $item)
        <div class="">
            post : {{ $item->id  }}: 
        </div>
    @endforeach
    <div>
        {{ $posts->onEachSide(1)->links() }}
    </div>
</div>

CommentComponent.php

class CommentComponent extends Component
{
    use WithPagination;
    public $commentsPage;

    public function render()
    {
        return view('livewire.comment-component', [
            'comments' => Comment::paginate(10, ['*'], 'commentsPage'),
        ]);
    }
}

comment-component.blade.php

<div>
    <div class="font-bold text-lg"> Comment-Component</div>
    <div > commentsPage : <span class="text-indigo-500 ">{{ $commentsPage }} </span></div>
    <hr class="h-4 "/>
    @foreach ($comments as $item)
        <div class="">
            {{ $item->id }} : comment :  
        </div>
    @endforeach
    <div>
        {{ $comments->onEachSide(1)->links() }}
    </div>
</div>

'commentsPage' pagination property does not as I expected.

Could someone check this bug ?

0 likes
2 replies
webrobert's avatar

@binggle, you do realize that this isn't an official support site, right? This is just a forum. I was part of a company once where if you had a great idea. You know the kind. When you can't help but blurt it out loud. Then that great idea became your new project. Maybe this bug is yours? I tease.

If you think it's truly a bug, report it on the livewire github, maybe?

webrobert's avatar

@binggle the example given in the docs does not show the use of the withPagination trait. Have you tried removing it?

Please or to participate in this conversation.