F
Filament14mo ago
Vishant

Focus on relation manager on page load

Is it possible to autofocus on the relation manager group instead of the edit form? I want the user to see the relation manager after record creation so they don't have to see the same form again.
5 Replies
bwurtz999
bwurtz99914mo ago
If you're on v3, you could use a one-off JS function to scroll to the bottom of the page when it loads
bwurtz999
bwurtz99914mo ago
Laravel
Actions | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
bwurtz999
bwurtz99914mo ago
$this->js(scroll-to-bottom-call); $this->js("window.scrollTo(0, document.body.scrollHeight);") should work You'll have to override the mount() function I think
Vishant
VishantOP14mo ago
Thanks for the answer. Where do I have to put that code..in the resource file itself (app\Filament\Resources\ExampleResource.php) or in the edit page of that resource file (app\Filament\Resources\ExampleResource\Pages\EditExample.php)?
bwurtz999
bwurtz99914mo ago
It looks like you want this to apply on the Edit page, so you would put it in EditExample.php
public function mount(int | string $record): void
{
$this->record = $this->resolveRecord($record);

$this->authorizeAccess();

$this->fillForm();

$this->previousUrl = url()->previous();

$this->js("window.scrollTo(0, document.body.scrollHeight);"); // this is the part you'll have to test
}
public function mount(int | string $record): void
{
$this->record = $this->resolveRecord($record);

$this->authorizeAccess();

$this->fillForm();

$this->previousUrl = url()->previous();

$this->js("window.scrollTo(0, document.body.scrollHeight);"); // this is the part you'll have to test
}
Want results from more Discord servers?
Add your server