Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CheckboxList does not display descriptions when using an enum for dynamic options #14501

Open
wants to merge 2 commits into
base: 3.x
Choose a base branch
from

Conversation

standaniels
Copy link
Contributor

Closes #14500

As this is my first pull request I need help with checking if this PR breaks existing functionality.

Description

When rendering a CheckboxList field with dynamic options where an enum is returned by the options closure, the descriptions are not displayed. This issue occurs even though the enum implements both HasDescription and HasLabel.

Visual changes

None.

Functional changes

  • Code style has been fixed by running the composer cs command.
  • Changes have been tested to not break existing functionality.
  • Documentation is up-to-date.

@ceejayoz
Copy link

I think this behavior might be intentional - not every CheckboxList needs descriptions, even if the enum has them.

You can already do ->options(Enum::class)->description(Enum::class) and it'll pick it up.

@standaniels standaniels force-pushed the fix-descriptions-for-dynamic-options branch from ba3f6f4 to 71a3457 Compare October 11, 2024 13:10
@standaniels
Copy link
Contributor Author

standaniels commented Oct 11, 2024

I agree not every CheckboxList needs descriptions, but when you pass an enum class to the options method descriptions are automatically added if this enum implements HasDescription. See the test in the first commit of this PR:

it('can render descriptions when enum implements HasDescription', function () {
    expect(Options::class)->toImplement(HasDescription::class);
    livewire(TestComponentWithFixedOptions::class)
        ->assertSeeText('Foo Description')
        ->assertSeeText('Bar Description');
});

This tests passes in the current version of Filament if you do ->options(Enum::class).

EDIT
Also, descriptions only accepts array | Arrayable | Closure. So ->descriptions(Enum::class) doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

Bug: CheckboxList does not display descriptions when using an enum for dynamic options
2 participants