RelationManager Page Url Paramater
In version 2 you could navigate to a specific page by using the url parameter
page=2
or in my case page=23421
, but it doesn't appear to work in v3.
I tried to no joy. Who has solved this?
9 Replies
page=2
still works on resources, but not relation managers.I think I need an input allowing a user to browse to a specific page.
@Mack H Hi! I looked into this and I had to go deep! It turns out that the issue is that relation managers use Livewire's
lazy
method meaning they don't load until you scroll them into view. This in turn is conflicting with Livewire's pagination. Not only does it not show, but even if you know the appropriate pagination key, it still won't load. You can see the problem by going to the relation-managers.blade.php
file and changing 'lazy' => true
to false
. Now the relation manager will load immediately and when you click on the next button the pagination url will appear. You can then use the url to navigate to a certain page.
After looking into this, I checked Livewire's PR's and there is actually an active PR failing test for this: https://github.com/livewire/livewire/pull/6760. (I wish I would have looked there first! 🤦‍♂️).
One option could be to make a PR to core to make lazy configurable...but I don't know if the team will accept it as they are trying to not add Livewire fixes to the core. You could make the argument that some devs may not want the RM to be lazy regardless, so maybe they would accept it?
Hope this helps!Wow, thanks. I did my own digging with my limited knowledge and couldn’t source it. Looking at the wire PRs would have been smart.
@Mack H I wanted to see how big a PR this would be, but I actually discovered that Filament already supports this! Just pass
'lazy' => false
to your relationManager.
Filament is great!One of the things I love about FIlament is just how extendable it is, but FUCK me there is now way it's this easy. I'm trying this in the morning. I'm forever in your debt.
No kidding. It's the best. I'm going to PR this to the docs for others
GitHub
Add docs on disabling lazy loading in relation managers by archilex...
RM's are lazy loaded by default. This causes an issue with pagination in Livewire per this discussion on discord and this PR in LW.
You can disable lazy loading in RMs by passing 'lazy'...
Worked perfect.