Skip to content

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

Open
@joshhanley

Description

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>

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions