spicywebau / craft-quick-field

Create Craft CMS fields on the fly while designing field layouts
MIT License
106 stars 6 forks source link

Neo field changed to Asset when edited in quick field #21

Open nstCactus opened 9 months ago

nstCactus commented 9 months ago

Bug Description

After editing a Neo field in quick-field from an entry type field layout, I noticed the field has changed to an Asset field.

While creating this ticket, I think I found the root cause of the issue: when the quick field modal window opens, the Field type dropdown isn't properly initialised and thus takes the value of the first <option>. If the user isn't extra careful when editing the field, he will overwrite the field type when saving.

Steps to reproduce

  1. Using Craft UI, create a Neo field, named "Main" (handle: contentBuildersMain)
  2. Go to an entry type and add the Neo field to it
  3. Save the entry type
  4. Edit the entry type again and edit the Neo field using quick field
  5. Set the name of the Neo field to "Content blocks"
  6. Save the Neo field
  7. Using Craft UI, edit the Neo field and notice its type has changed to Asset

Expected behaviour

The type of the Neo field should be kept when editing a field in quick field.

When the quick-field modal window opens, the Field type dropdown should be properly initialised with the current field type.

Quick Field version

2.0.5

Craft CMS version

4.5.6.1

ttempleton commented 9 months ago

Neo is intentionally filtered out of the available field types. I can't say for sure what the original reasoning was, since that was well before my time working on the plugin - but my guess would be that by allowing editing of Neo fields, which themselves load full field layout designers, you allow infinite Quick Field modals to be opened.

A potential solution is to allow Neo fields to be edited, but disallow Quick Field from initialising when the Neo field edit page is inside a modal. I'll need to look into that when I get a chance.