filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
18.72k stars 2.91k forks source link

unexpected behavior in repeater when perform actions #7485

Closed atmonshi closed 1 year ago

atmonshi commented 1 year ago

Package

filament/filament

Package Version

v3.0.8

Laravel Version

10.17.1

Livewire Version

v3.0.0-beta.7

PHP Version

8.1.21

Problem description

There is unexpected behavior when performing some actions for the repeater like deleting item or resort etc

If the repeater contains some components like toggle, select, and markdown editor.

Some time won't delete or delete with the next action (request), and when adding an item, it will add two items or more.

Initially, I thought it was a LW queuing the requests or something like that, but when I removed the Toggle, all was good I am unsure if the issue is with the repeater or the other components. For example, the MarkdownEditor is duplicated when clicking any action.

I let you watch the two videos...

with toggle https://github.com/filamentphp/filament/assets/1952412/d88effa1-5f87-432d-94fd-f066feead1fc

without toggle https://github.com/filamentphp/filament/assets/1952412/fccc6c93-57f7-40c3-87d5-b98aff24e5b2

I have a repo ready for testing but here is the simple code:

public static function form(Form $form): Form
{
    return $form
        ->schema([
            TextInput::make('name'),
            Repeater::make('repeated_text')
                ->label('No Toggle')
                ->schema([
                    TextInput::make('name'),
                    //Toggle::make('aside'),
                ])->grid(2)
        ]);
}

Expected behavior

when deleting an item should be deleted. when clicking add an item it should add one new item

Steps to reproduce

go to /admin click Forms > create form click add to items multiple times delete any item add more items you will notice the total items are not the same.

Another way you can see the issue live: https://demo.larazeus.com/admin/forms/create click add section multiple times, and delete any section.

Reproduction repository

https://github.com/lara-zeus/test-fila-three/pull/3

Relevant log output

There are no console logs or exceptions
atmonshi commented 1 year ago

feedback from the community https://discord.com/channels/883083792112300104/1137187589930094693

mustafa-online commented 1 year ago

Same issue here too after updating to v3, but with a select component inside repeater. 😣

danharrin commented 1 year ago

Just to let you know we are looking into this. I believe that #7421, #7450, #7475 and #7485 (and other duplicate issues) are all the same bug, related to Livewire's entangle feature.

danharrin commented 1 year ago

livewire/livewire#6289

atmonshi commented 1 year ago

did a quick test seems it fixed my issue 🎉

if you want to test: add "livewire/livewire": "dev-main as 3.0",

and do

composer update -W

njxqlus commented 1 year ago

the MarkdownEditor is duplicated when clicking any action

The problem still exists after updating composer.json "livewire/livewire": "dev-main as 3.0"

njxqlus commented 1 year ago

https://github.com/livewire/livewire/pull/6289 merged in v3.0.0-beta.9. The problem with MarkdownEditor still exists.

Forms\Components\Repeater::make('foo')->schema([
    Forms\Components\MarkdownEditor::make('bar')
])
danharrin commented 1 year ago

@njxqlus please open a new issue as the current reproduction repository doesnt cover using a markdown editor

mikemathewson commented 1 year ago

I'm still experiencing this issue with Livewire v3.0.0-beta.9

It seems to be related to Filament's custom input fields, e.g. toggle, non-native datepicker, searchable select, etc.

danharrin commented 1 year ago

Please open an issue with a reproduction repository as the original one that was posted now works.