Skip to content

File sorting doesn't work in files sections that use "parent" #2617

@rasteiner

Description

@rasteiner

Describe the bug
Sorting files has no effect in files sections when they use the parent option.

To Reproduce
Steps to reproduce the behavior:

  1. Create a files section with a parent option in a page blueprint:
    site/blueprints/pages/home.yml
sections:
  myfiles:
    type: files
    parent: site.find('otherpage')
  1. Log into panel and create a 'otherpage' page, then go to the home
  2. Upload some files to the section
  3. Drag to sort some files
  4. Reload. The files didn't save their order

Expected behavior
Files should be manually sortable even if they're saved in another page.

Kirby Version
3.3.6

Console output
no errors or warnings.

Additional context
Looking at network traffic, I see that sorting the files sends a PATCH request to the wrong parent (the "current page", not the real parent of the files). E.g if the section lives in home and the files come from otherpage, the request looks like this:

PATCH /api/pages/home/files/sort

{
  "files": [
    "otherpage/3.jpg",
    "otherpage/2.jpg",
    "otherpage/1.jpg"
  ],
  "index":0
}

But I guess it should PATCH to :

PATCH /api/pages/otherpage/files/sort

Inspecting the <KFilesSection> component; the props contain a parent property that seems wrong (it links to the current page). However, in data, there's an options.upload.api value that points to the correct parent.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions