Skip to content

Filename preview issues with InputfieldFile in "old school" mode #964

@Toutouwai

Description

@Toutouwai

Short description of the issue

When InputfieldFile is used outside of Page Edit it seems to operate in "old school" mode - it uses InitOldSchool() in InputfieldFile.js.

In this mode there are a couple of issues with the preview of filenames that have been uploaded to the field before the form is submitted.

For testing purposes I used some custom JS to get the filenames that have been added to the inputs:

$(document).on('change', '.InputfieldFileUpload input[type=file]', function() {
    // Get the names of all the files added to the inputs
    var $container = $(this).closest('.InputfieldFile');
    var $inputs = $container.find('input[type=file]');
    var filenames = [];
    $inputs.each(function() {
        var files = $(this)[0].files;
        for(var i = 0; i < files.length; i++) {
            file = files[i];
            filenames.push(file.name);
        }
    });
    // Log to console
    console.log(filenames);
});

1. When files are added one-by-one to the field then each file is listed in the preview, which is good.

2019-08-21_102230

But when multiple files are added at once only one file is shown in the preview.

2019-08-21_102301

2. When a file is replaced (by clicking on that file in the preview and selecting a different file), the file is indeed replaced in the input value but the preview does not update to reflect the new filename.

f1

Setup/Environment

  • ProcessWire version: 3.0.137

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions