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.61k stars 2.9k forks source link

Widgets on create record page are breaking the form with the repeater field #1140

Closed pavlentij closed 2 years ago

pavlentij commented 2 years ago

Package

filament/filament

Package Version

v2.8.1

Laravel Version

v8.78.0

Livewire Version

v2.8.2

PHP Version

PHP 8.1.0

Bug description

Create/edit record pages are not properly working if we have multiple widgets in the header or footer, and there is at least one record in the repeater field.

The issue in the nested Livewire widgets` components inside the form. It's causing JS error during the preloading of children components for the repeater field.

I've found a quick solution to add keys to widgets loops.

        @if ($headerWidgets = $this->getHeaderWidgets())
            <x-filament::widgets>
                @foreach ($headerWidgets as $i => $widget)
                    @livewire(\Livewire\Livewire::getAlias($widget), ['record' => $widgetRecord], key('header-widget-' . $i))
                @endforeach
            </x-filament::widgets>
        @endif

But maybe there is a better solution.

Steps to reproduce

  1. Create a resource with the repeater field.
  2. Set amount of default items in the repeater to more than 1.
  3. Add multiple widgets to the header of the create record page.
  4. Go to the create record page.

Relevant log output

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'fingerprint')
    at new Component (index.js:34)
    at onNodeAdded (index.js:496)
    at callHook (morphdom.js:35)
    at handleNodeAdded (morphdom.js:140)
    at morphdom.js:407
    at morphEl (morphdom.js:219)
    at morphdom.js:332
    at morphEl (morphdom.js:219)
    at morphdom.js:332
    at morphEl (morphdom.js:219)
danharrin commented 2 years ago

Should be fixed by #1144. It'll be available in the next release. Let me know if it helps.

pavlentij commented 2 years ago

It's working. Thanks.