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

Select Multiple with disableOptionWhen has issue #15854

Open
dharen008 opened this issue Mar 13, 2025 · 2 comments
Open

Select Multiple with disableOptionWhen has issue #15854

dharen008 opened this issue Mar 13, 2025 · 2 comments
Labels
Milestone

Comments

@dharen008
Copy link

dharen008 commented Mar 13, 2025

Package

filament/filament

Package Version

3.2

Laravel Version

11.9

Livewire Version

3.0

PHP Version

8.4

Problem description

The disableOptionWhen feature has an issue in multiple select mode. It only works if the dropdown reloads, but if you keep selecting options without triggering onBlur or clicking outside the field, disableOptionWhen does not apply.

Reference video here
https://app.screencast.com/xevYk1zCI9WJK

Here's my code:
Select::make( 'options' ) ->options( [ 'Option 1' => 'Option 1', 'Option 2.1' => 'Option 2.1', 'Option 2.2' => 'Option 2.2', ] ) ->disableOptionWhen( function ( string $value, Get $get ) { if ( in_array( 'Option 2.1', $get( 'options' ) ) ) { return $value === 'Option 2.2'; } if ( in_array( 'Option 2.2', $get( 'options' ) ) ) { return $value === 'Option 2.1'; } } ) ->label( 'Select Multiple' ) ->multiple() ->required() ->live()

Here's the path to the demo file
app\Filament\Resources\UserResource.php

Expected behavior

it should use disableOptionWhen right after selecting a option

Steps to reproduce

Follow the Reference video here
https://app.screencast.com/xevYk1zCI9WJK

Reproduction repository (issue will be closed if this is not valid)

https://github.com/dharen008/demo/blob/main/app/Filament/Resources/UserResource.php

Relevant log output

@thethunderturner
Copy link
Contributor

thethunderturner commented Mar 13, 2025

Try this:

Select::make( 'options' )
	->options( [
		'Option 1'  => 'Option 1',
		'Option 2.1' => 'Option 2.1',
		'Option 2.2' => 'Option 2.2',
	] )
        ->disableOptionWhen(function ($value): bool {
            return $value === 'Option 2.2' || $value === 'Option 2.3';
        })
	->label( 'Select Multiple' )
	->multiple()
	->required(),

@dharen008
Copy link
Author

Try this:

Select::make( 'options' )
->options( [
'Option 1' => 'Option 1',
'Option 2.1' => 'Option 2.1',
'Option 2.2' => 'Option 2.2',
] )
->disableOptionWhen(function ($value): bool {
return $value === 'Option 2.2' || $value === 'Option 2.3';
})
->label( 'Select Multiple' )
->multiple()
->required(),

it just disabled both option. watch the link i send there so you know what is the main issue

@dharen008 dharen008 changed the title Select Multiple with disableOptionWhen is not working Select Multiple with disableOptionWhen has issue Mar 14, 2025
@danharrin danharrin added this to the v3 milestone Mar 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

3 participants