Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flux Editor throws errors when used in a loop that changes order #806

Open
joshhanley opened this issue Dec 4, 2024 · 0 comments
Open
Assignees

Comments

@joshhanley
Copy link
Member

joshhanley commented Dec 4, 2024

Currently if you use the Editor component in a loop and change the order of the loop or prepend to it, the following error gets thrown multiple times. But if you just append to the loop, it doesn't throw any errors. Interestingly even though the error gets thrown, all editors still seem to function as expected.

Image

Open the below Volt component in your browser and open the console, then either click Append Item which should work fine, or click Prepend Item which throws the error.

<?php

use Livewire\Volt\Component;

new class extends Component {

    public $items = [
        'a' => 'a',
        'b' => 'b',
        'c' => 'c',
    ];

    public function prependItem()
    {
        $this->items = ['z' => 'z'] + $this->items;
    }

    public function appendItem()
    {
        $this->items['d'] = 'd';
    }
};
?>

<flux:main container>
    <div>
        @foreach($items as $key => $value)
            <div wire:key="{{ $key }}">
                <flux:editor wire:model.live="items.{{ $key }}" :wire:key="'editor-' . $key" />
                <p>Value: {{ $value }}</p>
            </div>
        @endforeach
    </div>

    <button wire:click="prependItem">Prepend Item</button>
    <button wire:click="appendItem">Append Item</button>
</flux:main>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant