CodeWithDennis / filament-select-tree

The multi-level select field lets you pick one or multiple options from a list that is neatly organized into different levels.
MIT License
207 stars 28 forks source link

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

Open nocodelab opened 10 months ago

nocodelab commented 10 months ago

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

CodeWithDennis commented 9 months ago

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.

nocodelab commented 9 months ago

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!

CodeWithDennis commented 9 months ago

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

nocodelab commented 9 months ago

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...

CodeWithDennis commented 9 months ago

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.

ralphjsmit commented 9 months ago

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

CodeWithDennis commented 9 months ago

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);
}
chandraauliatama commented 5 months ago

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

nocodelab commented 5 months ago

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: @.***>