Closed AnnikaGruca-JUNO closed 10 months ago
@bastianallgeier found the source of this issue: https://github.com/getkirby/kirby/blob/main/panel/src/panel/upload.js#L293
When there is no template and not sortable, attributes
is actually empty (see https://github.com/getkirby/kirby/blob/main/config/sections/files.php#L194-L200). In turn, attributes
is not an empty object but actually ends up as an empty array in JS world. And .sort
on an array is a method, which is why the if statement gets entered and then NaN
is the result.
Some ideas:
Array.isArray(this.attributes) === false
in upload.js
array_filter
call from fields.php
to ensure that attributes
is always an object
Description
When uploading a file in a section without a defined file template and
sortable: false
,Sort: NaN
is inserted in the file’s content file. The file is then displayed at the end the section.Expected behaviour
In Kirby 3, the files were sorted by name.
To reproduce
Can be reproduced in the Starterkit in
site/blueprints/pages/album.yml
from line 40:Your setup
Kirby Version
4.0.1