filament icon indicating copy to clipboard operation
filament copied to clipboard

Builder reactivity broken when using previews

Open martin-ro opened this issue 1 year ago • 1 comments

Package

filament/filament

Package Version

v3.2.99

Laravel Version

v11.20.0

Livewire Version

No response

PHP Version

PHP 8.2

Problem description

When using the blockPreviews for Builder the reactivity in the modal form doesn't work once the block is saved.

https://github.com/user-attachments/assets/0fb1a824-7025-4f7e-937e-9d1523ea96d1

Expected behavior

Same as without blockPreviews

Steps to reproduce

See https://github.com/martin-ro/block-builder (UserResource)

or

add this to a from:

Forms\Components\Builder::make('blocks')
                    ->blockPreviews()
                    ->schema([
                        Forms\Components\Builder\Block::make('test')
                            ->preview('components.test')
                            ->schema([
                                Forms\Components\Checkbox::make('is_company')
                                    ->live(),

                                Forms\Components\TextInput::make('company_name')
                                    ->hidden(fn(Forms\Get $get): bool => !$get('is_company'))
                            ])
                    ])

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

https://github.com/martin-ro/block-builder

Relevant log output

No response

Donate 💰 to fund this issue

  • You can donate funding to this issue. We receive the money once the issue is completed & confirmed by you.
  • 100% of the funding will be distributed between the Filament core team to run all aspects of the project.
  • Thank you in advance for helping us make maintenance sustainable!
Fund with Polar

martin-ro avatar Aug 16 '24 21:08 martin-ro

Another observation I just made is that wrapping components in for example a group or fieldset reactivity works inside it. So this is only broken for "top level" components.

martin-ro avatar Oct 02 '24 02:10 martin-ro

@danharrin this seems to be already fixed, at least in the latest version [v3.2.136]

https://youtu.be/SNWtRdyG2Sg

Additionally, the given repository does not exist. regards

borjajimnz avatar Feb 04 '25 23:02 borjajimnz

@martin-ro can you confirm please?

danharrin avatar Feb 05 '25 13:02 danharrin

@martin-ro can you confirm please?

Yes @danharrin, the issue persists. The yt video @borjajimnz posted never saved the model so it appears it is working.

Steps to reproduce:

  1. Add Test block
  2. Check checkbox
  3. Enter name
  4. Save block
  5. Save record

Reactivity works so far

  1. Uncheck checkbox
  2. Save block
  3. Save record

Now reactivity is broken, you can not get the TextInput to be shown anymore.

I pushed another repo here: https://github.com/martin-ro/filament-reactivity/

On the UserResource there is a commented second example that works because the fields in the block are wrapped in a group.

martin-ro avatar Feb 05 '25 21:02 martin-ro

Yes, @martin-ro, I can reproduce this now. I'll give it a shot. Thanks!

borjajimnz avatar Feb 05 '25 23:02 borjajimnz