FilamentF
Filament2y ago
2 replies
∂evelopeɾ

[bug] Resource infolist modal not working as expected

Encountered this little bug, where having an Infolist that needs to open in a modal from the Tables\Actions\ViewAction::make()->slideOver() stops working upon setting 'view' => Pages\ViewPost::route('/{record}') in the getPages() of the Resource (it opens as a full-page, not as a modal)
-------
The thing is, I need to have both functions active since I would like to be able to open a modal from the Resource itself and also be able to open the infolist in a separate full-page window

EDIT: if you want to reproduce this behavior just add the corresponding view or edit page to the getPages() of your resource like this:
    public static function getPages(): array
    {
        return [
            'index' => Pages\ListPosts::route('/'),
            'view' => Pages\ViewPost::route('/{record}'),
            'edit' => Pages\EditPost::route('/{record}/edit')
            ...
        ];
    }

also add the ViewAction action in the table() method of the Resource like this:
    ->actions([
        Tables\Actions\ViewAction::make()->slideOver(), // I like the slideover modal
        Tables\Actions\EditAction::make(),
        Tables\Actions\DeleteAction::make(),
    ])

When the view page is present in the getPages() the modal don't open as a modal but as full-page (at this point I'm just repeating myself sorry)
now you may wondering, why don't you just remove the view page from the getPages() then?...
because, issue is that by removing the view page, I'll consequently disable the view route, preventing access from other resources:
Route [filament.admin.resources.posts.view] not defined.
Was this page helpful?