cms icon indicating copy to clipboard operation
cms copied to clipboard

File field in navigation blueprint resets preview when sidepanel closes

Open mawalu opened this issue 9 months ago • 5 comments

Bug description

We have a file field to upload images in our navigation blueprint. When a user sets an image, saves the navigation item and reopens the navigation item side panel without reloading, the file field is no longer populated but defaults to the empty state.

After the tree is saved and the page reloaded the field is populated correctly but this behavior causes confusion to users.

How to reproduce

  • Add a file field to a navigation blueprint
  • Choose a file for a navigation item and save the item
  • Click again on the same navigation item opening the side panel, without saving the tree or reloading first
  • See that the file field is not showing your selected file as value

Happens both with newly uploaded files and existing files

Logs


Environment

$ php please support:details

Environment
Application Name: xxx
Laravel Version: 10.48.28
PHP Version: 8.2.24
Composer Version: 2.8.3
Environment: local
Debug Mode: ENABLED
URL: xxx.ddev.site
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: redis
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Livewire
Livewire: v3.5.19

Statamic
Addons: 2
Sites: 6 (xxx - DE, xxx - EN, xxx - DK, and 3 more)
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 5.51.0 PRO

Statamic Addons
appswithlove/statamic-one-click-content-translation: 5.2.3
thoughtco/statamic-restrict-fields: 1.1.0

Installation

Existing Laravel app

Additional details

This issue already existed on previous versions, I just updated to verify it still affects the latest one

mawalu avatar Mar 18 '25 10:03 mawalu

The "Files" fieldtype is only really intended to be used on forms and by addon developers. It only uploads the file, it doesn't actually handle storing it.

You should probably be using the Assets fieldtype instead.

duncanmcclean avatar Mar 18 '25 10:03 duncanmcclean

Thank you for your response and sorry for the inaccuracy, but we are using a type: assets field for this. At least in the translated version of the CP the Fieldtype is called "Files" in the ui, thats why I referred to it that way.

-
  handle: headerimage
  field:
    max_files: 1
    container: images
    type: assets
    display: 'Headerbild'
    localizable: false

Can this be reopened?

mawalu avatar Mar 18 '25 12:03 mawalu

This looks like the same underlying issue as #10630. When you re-open a nav item after saving, the preview isn't displayed. It works as expected after refreshing the page.

duncanmcclean avatar Mar 20 '25 16:03 duncanmcclean

The issue affects all fields in the nav blueprint not just asset fields :/

Image

nav_test.yaml

tabs:
  main:
    display: Main
    sections:
      -
        fields:
          -
            handle: assets_field
            field:
              container: assets
              type: assets
              display: 'Assets Field'
          -
            handle: replicator_field
            field:
              type: replicator
              display: 'Replicator Field'
              sets:
                new_set_group:
                  display: 'New Set Group'
                  sets:
                    new_set:
                      display: 'New Set'
                      fields:
                        -
                          handle: text_field
                          field:
                            type: text
                            display: 'Text Field'

o1y avatar Apr 23 '25 14:04 o1y

The issue is that when you close the PageEditor.vue, the entire VueX state gets destroyed. This results in losing all the meta data.

https://github.com/statamic/cms/blob/573d366fe749ea1f6b847f1aafcbe1883d04e255/resources/js/components/publish/Container.vue#L65-L69

o1y avatar Apr 23 '25 17:04 o1y

This has been fixed in Statamic 6, which is due to be released ~Q3, with an alpha on its way in the next week or so. You can learn more about v6 on our blog.

duncanmcclean avatar Aug 13 '25 13:08 duncanmcclean