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.09k stars 2.83k forks source link

Select options: change options array -> state no selected (native only) #8972

Closed MichaelMdp closed 11 months ago

MichaelMdp commented 11 months ago

Package

filament/filament

Package Version

v3.0.62

Laravel Version

10.24.0

Livewire Version

v3.0.5

PHP Version

8.1.16

Problem description

On a filament forms select field: After you have a value selected for the an option, if you change the items created by the options closure (e.g.: remove an item from the list) The selected value is no longer selected in the UI, even if it has the exact same key.

When the property is flagged as a url param, you can refresh the page and the value is selected again.

It only seems to occur when an item, before the selected item, is removed from the options array. When the first item was selected and items after the selection are removed, it stays selected.

This was working in v2. this issue is only present for the native select.

Expected behavior

the selected value stays selected in the UI, even if the underlying options array is updated.

Steps to reproduce

artisan migrate:fresh go to the homepage / a form is visible with 2 dropdowns.

image

=> the initial selection is no longer visualised in the UI.

image

see App\Livewire\DropdownTest.php

Reproduction repository

https://github.com/MichaelMdp/filamentv3-options-update-issue

Relevant log output

No response

zepfietje commented 11 months ago

Might this be caused by this Livewire bug, @MichaelMdp? https://github.com/livewire/livewire/pull/6984

austincarpenter commented 11 months ago

Could be this too https://github.com/livewire/livewire/pull/6889

zepfietje commented 11 months ago

Oh, I think I was actually looking to reference your PRs, @austincarpenter. 😄

Closing as this is most probably https://github.com/filamentphp/filament/pull/8633.