filament-select-tree icon indicating copy to clipboard operation
filament-select-tree copied to clipboard

[Bug]: Option duplications when used within a sortable Repeater

Open nocodelab opened this issue 1 year ago • 9 comments

What happened?

When the SelectTree field is used within a sortable Repeater a duplication behaviour happens. Have a look at the video attached:

https://github.com/CodeWithDennis/filament-select-tree/assets/4540118/e4de4930-f73a-420e-8133-a81a3c7198d8

How to reproduce the bug

Simply use the SelectTree field in any repeater.

Package Version

3.1

PHP Version

8.2

Laravel Version

10

Which operating systems does with happen with?

No response

Notes

No response

nocodelab avatar Nov 16 '23 10:11 nocodelab

I checked with others, and it appears there's a bug in async Alpine. @nocodelab

this is a bug in async alpine. the PR was just merged and released. will update filament as soon as possible.

CodeWithDennis avatar Dec 18 '23 15:12 CodeWithDennis

I checked with others, and it appears there's a bug in async Alpine. @nocodelab

this is a bug in async alpine. the PR was just merged and released. will update filament as soon as possible.

that's great! thanks @CodeWithDennis!

nocodelab avatar Dec 18 '23 15:12 nocodelab

It looks like the issue isn't solved in the latest Filament release. I'll need to investigate more and might ask for assistance.

CodeWithDennis avatar Dec 19 '23 14:12 CodeWithDennis

Maybe it's related to the wire:key assignment. I saw here https://github.com/CodeWithDennis/filament-select-tree/blob/3.x/resources/views/select-tree.blade.php that you are assigning a rand() value. How come? Maybe that breaks after the reorder...

nocodelab avatar Dec 19 '23 14:12 nocodelab

Maybe it's related to the wire:key assignment. I saw here https://github.com/CodeWithDennis/filament-select-tree/blob/3.x/resources/views/select-tree.blade.php that you are assigning a rand() value. How come? Maybe that breaks after the reorder...

Yes, this creates problems, but without it, the field won't be reactive/live. So, we have to find a better solution.

CodeWithDennis avatar Dec 19 '23 14:12 CodeWithDennis

Why is the field not reactive/live without setting the wire:key to rand()?

ralphjsmit avatar Dec 19 '23 14:12 ralphjsmit

Why is the field not reactive/live without setting the wire:key to rand()?

Adding wire:key also makes the field flicker. So, we gotta figure out a better way to fix this. Without the wire:key the field won't be disabled.

(Removing the wire:key doesn't solve this issue BTW)

public static function form(Form $form): Form
{
    return $form
        ->schema([
            Forms\Components\TextInput::make('name')
               ->live(),
            SelectTree::make('categories')
                ->placeholder(__('Select categories'))
                ->label(__('Categories'))
                ->relationship('categories', 'name', 'parent_id')
                ->enableBranchNode()
                ->disabled(fn(Forms\Get $get) => filled($get('name'))),
        ])->columns(1);
}

CodeWithDennis avatar Dec 19 '23 15:12 CodeWithDennis

@nocodelab any update on this one? did you fix your problem?

chandraauliatama avatar Apr 16 '24 11:04 chandraauliatama

Nope, I just switched to normal select inputs…Giuseppe M.Sent from my iPhone 📱 / Excuse my brevityOn 16 Apr 2024, at 13:44, Chandra Aulia Tama @.***> wrote: @nocodelab any update on this one? did you fix your problem?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

nocodelab avatar Apr 16 '24 11:04 nocodelab