Force refresh a Select to update disableOptionWhen()?

Hey, I would really apprecaite some pointers in the right direction here, I've tried absolutely everything I can think of.

In my Select implementation, I am trying to Remove/Disable options in real-time based on current selection.

The code below works, however, the options are only updated when you exit focus from the Select and click on it again.

What could I do to force the options to refresh whenever the state is changed?

Or is there a better way to approach this? The goal is to be able to select only x1 Category of each type.

Eg: If the select is showing (A1, A2, A3, B1,B2, B3) and you select A1, I want to immediately remove/disable (A2, A3) and the new options state would be ( B1,B2, B3).

I have been able to do it with validation, but it is not ideal.

    Forms\Components\Select::make('categories')
        ->relationship('categories', 'name')
        ->multiple()
        ->preload()
        ->live()
        ->options(fn (Get $get) => static::getCategoryOptions($get))
        ->disableOptionWhen(function (string $value, Get $get): bool {
            return static::shouldDisableCategory($value, $get);
        })

    
Was this page helpful?