Skip to content

Add collapsible() and collapsed() methods to AuditsRelationManager #61

@donaldallen

Description

@donaldallen

Feature Request

Description

Add collapsible() and collapsed() methods to AuditsRelationManager to match the functionality available in Filament v4 Sections. This would allow us to optionally make the audits section collapsible and/or collapsed by default.

Use Case

For resources with extensive audit histories, having collapsible audit sections would:

  • Improve UX by reducing visual clutter while keeping audits accessible
  • Give developers control over when to show/hide audits based on their use case
  • Allow conditional collapsing based on feature flags or other conditions

Proposed Solution

Implement collapsible() and collapsed() methods similar to Filament v4 Sections:

Basic collapsible (user can expand/collapse):

class AuditsRelationManager extends BaseAuditsRelationManager
{
    protected function collapsible(): bool
    {
        return true;
    }
}

Collapsed by default:

class AuditsRelationManager extends BaseAuditsRelationManager
{
    protected function collapsible(): bool
    {
        return true;
    }

    protected function collapsed(): bool
    {
        return true;
    }
}

With conditional logic (matching Filament Section API):

class AuditsRelationManager extends BaseAuditsRelationManager
{
    protected function collapsible(): bool
    {
        return FeatureFlag::active('collapsible_audits');
    }

    protected function collapsed(): bool
    {
        return FeatureFlag::active('collapsed_audits_by_default');
    }
}

Filament v4 Sections currently support this pattern:

Section::make('Cart')
    ->description('The items you have selected for purchase')
    ->schema([
        // ...
    ])
    ->collapsible()
    ->collapsed()

These methods also accept boolean parameters for conditional behavior:

->collapsible(FeatureFlag::active())
->collapsed(FeatureFlag::active())

Happy to create a PR for this if you think it's worthwhile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions