Problem/Motivation

In terms of interaction, file fields could be a lot more accessible. The style guide proposes both a new appearance and a new interaction design.

Proposed resolution

  1. Files can be added from the local filesystem using drag-and-drop, or using the traditional click-browse-attach workflow (which hands the action off to the OS and back)
  2. Files upload automatically once added by dropping or browsing.
  3. Uploaded files provide a preview where possible (images) or a file-type-specific icon where not.
  4. File fields with multiple attachments use progressive disclosure to reveal each additional slot in turn. They should support dropping multiple files onto a single dropzone to upload multiple files at once.
  5. The “Browse Library” functionality is speculative at this time, but designed to accommodate contrib.
  6. Some aspects of the design are postponed to follow ups (improving multiple file fields, the progress bar, mobile improvements). See the complete list below.

An important reason to encapsulate much of this functionality, is that it tends to scale much better amongst many items and especially if placed between forms it can serve as a clear visual landmark.

Aspects of proposed design postponed to follow-ups

11.file-field.png

Test Pages

  • A file field will have to be created and add to an existing content type

Screenshots (patch #191)

Empty file/image fields
Empty file/image fields

Filled file/image fields
Filled file/image fields

CommentFileSizeAuthor
#251 2113931-251.patch46.49 KBjerrylow
#250 2113931-250-patch-sample.png133.93 KBjerrylow
#250 2113931-250.patch47.25 KBjerrylow
#250 interdiff-247-250.txt639 bytesjerrylow
#249 2113931-248.missing-remove-on-multiple.png90.15 KBjerrylow
#247 2113931-247.patch47.24 KBseanb
#247 interdiff-244-247.txt1.54 KBseanb
#244 2113931-244.patch47.78 KBseanb
#244 interdiff-238-244.txt2.47 KBseanb
#239 2113931-239.file-name-and-size-wrapping-funny.png97.99 KBdww
#239 2113931-239.seven-big-filename-after-patch.png151.63 KBdww
#239 2113931-239.seven-big-filename-before-patch.png168.05 KBdww
#238 2113931-238.patch46.93 KBseanb
#238 interdiff-234-238.txt5.91 KBseanb
#236 2113931-236-file-card3-full.png70.4 KBdww
#236 2113931-236-file-card3-2-up.png90.58 KBdww
#236 2113931-236-field-widget-settings.png32.49 KBdww
#236 2113931-236-field-widget-summary.png21.07 KBdww
#236 2113931-236-remove-text-classes-with-filename-hover.png93.07 KBdww
#236 2113931-236-remove-text-classes-with-filename.png92.46 KBdww
#235 2113931-234.patch44.24 KBseanb
#235 interdiff-231-234.txt6.25 KBseanb
#231 2113931-231.patch44.4 KBseanb
#231 interdiff-229-231.txt4.93 KBseanb
#230 Screen Shot 2019-02-25 at 18.00.10.png15.07 KBlauriii
#229 2113931-229.patch43.68 KBseanb
#229 interdiff-227-229.txt9.97 KBseanb
#228 Screenshot 2019-02-22 at 17.43.26.png65.96 KBwim leers
#227 2113931-227.patch43.82 KBseanb
#227 interdiff-224-227.txt3.52 KBseanb
#224 2113931-224.patch43.85 KBseanb
#224 interdiff-223-224.txt3.53 KBseanb
#223 2113931-223.patch43.74 KBseanb
#223 interdiff-215-223.txt1.44 KBseanb
#222 215-limited-files-notice.png31.41 KBbrankoc
#222 215-unlimited-files-error-message.png13.51 KBbrankoc
#222 215-multiple-files-before-and-after-upload.png22.85 KBbrankoc
#222 215-single-image-before-and-after-upload.png30.1 KBbrankoc
#221 215-bug-single-image-error-message.png7.77 KBbrankoc
#219 a0bbc77d8ffd4de9895f7110f46d0144.png160.7 KBfinnsky
#215 2113931-215.patch43.04 KBseanb
#215 interdiff-214-215.txt407 bytesseanb
#214 2113931-214.patch43.02 KBseanb
#214 interdiff-209-214.txt21.98 KBseanb
#214 after-rtl.png51.61 KBseanb
#214 after.png50.96 KBseanb
#214 before.png39.75 KBseanb
#213 Screen Shot 2019-02-14 at 23.59.14.png62.78 KBlauriii
#209 2113931-209.patch33.73 KBseanb
#209 interdiff-208-209.txt1.02 KBseanb
#208 interdiff-2113931-198_208.txt871 bytesbrankoc
#208 2113931-208.patch33.71 KBbrankoc
#199 vokoscreen-2019-02-01_16-51-27.avi1.86 MBKondratievaS
#198 interdiff-193-198.txt4.98 KBseanb
#198 2113931-198.patch33.65 KBseanb
#197 selected_3732.png72.47 KBKondratievaS
#196 2113931-193-file-field-preview-narrow.png44.11 KBbrankoc
#193 interdiff.txt4.36 KBlauriii
#193 2113931-193.patch32.87 KBlauriii
#191 2113931-191.patch33.46 KBseanb
#191 interdiff-182-191.txt7.78 KBseanb
#191 filled-ltr.png1.22 MBseanb
#191 empty-ltr.png712.51 KBseanb
#182 2113931-182.patch33.66 KBseanb
#182 interdiff-176-182.txt15.44 KBseanb
#181 2113931-181.interdiff.diff3.52 KBskaught
#181 2113931-181.patch4.67 KBskaught
#179 Screen Shot 2019-01-25 at 18.33.26.png47.38 KBlauriii
#179 Screen Shot 2019-01-25 at 18.30.06.png6.26 KBlauriii
#179 Screen Shot 2019-01-25 at 18.26.42.png38.51 KBlauriii
#179 Screen Shot 2019-01-25 at 18.26.28.png227.94 KBlauriii
#176 field-filled.png1.25 MBseanb
#176 field-empty.png783.56 KBseanb
#176 interdiff-172-176.txt2.51 KBseanb
#176 2113931-176.patch32.07 KBseanb
#173 2113931-171-file-field-single-file-description.png8.91 KBbrankoc
#172 after-default-image-dropzone.png101.06 KBseanb
#172 before-default-image-dropzone.png75.34 KBseanb
#172 after-default-image-no-js.png101.38 KBseanb
#172 before-default-image-no-js.png74.71 KBseanb
#172 interdiff-169-171.txt2.42 KBseanb
#172 2113931-171.patch31.49 KBseanb
#169 interdiff-167-169.txt17.07 KBseanb
#169 2113931-169.patch30.52 KBseanb
#168 2113931-167-file-field-display-column.png16.04 KBbrankoc
#168 2113931-167-file-field-single-uploaded.png2.71 KBbrankoc
#168 2113931-167-file-field-carriage-return-in-description.png9.63 KBbrankoc
#168 2113931-167.patch37.7 KBbrankoc
#167 interdiff-2113931-166_167.txt1.87 KBbrankoc
#166 interdiff-162-166.txt9.19 KBseanb
#166 2113931-166.patch37.69 KBseanb
#165 2113931-single-image-uploaded-helptext.png18.12 KBbrankoc
#165 2113931-single-file-uploaded-large-helptext.png11.42 KBbrankoc
#165 2113931-single-file-large-helptext.png17.49 KBbrankoc
#165 2113931-165.patch37.28 KBbrankoc
#165 interdiff-2113931-162_165.txt824 bytesbrankoc
#162 interdiff-161-162.txt509 bytesseanb
#162 2113931-162.patch37.33 KBseanb
#161 interdiff-158-161.txt1.07 KBseanb
#161 2113931-161.patch37.46 KBseanb
#160 default-image-uploaded-no-js.png22.54 KBseanb
#160 default-image-uploaded.png112.42 KBseanb
#160 default-image-no-js.png103.86 KBseanb
#160 default-image.png111.45 KBseanb
#160 multi-file-image-uploaded-no-js.png313.19 KBseanb
#160 multi-file-image-uploaded-rtl.png339.69 KBseanb
#160 multi-file-image-uploaded.png340.05 KBseanb
#160 multi-file-image-no-js.png86.82 KBseanb
#160 multi-file-image-rtl.png101.61 KBseanb
#160 multi-file-image.png100.72 KBseanb
#160 single-file-image-uploaded-no-js.png114.75 KBseanb
#160 single-file-image-uploaded-rtl.png135.54 KBseanb
#160 single-file-image-uploaded.png133.97 KBseanb
#160 single-file-image-no-js.png55.79 KBseanb
#160 single-file-image-rtl.png63.41 KBseanb
#160 single-file-image.png63.45 KBseanb
#158 interdiff-148-158.txt39.41 KBseanb
#158 2113931-158.patch36.39 KBseanb
#154 2113931-154.patch28.84 KBvacho
#148 interdiff-145-148.txt7.82 KBbrankoc
#148 2113931-148.patch28.71 KBbrankoc
#147 file-field-single-image-overflow.png31.22 KBbrankoc
#147 file-field-nojs.png9.03 KBbrankoc
#147 file-field-after-flawless.png15.97 KBbrankoc
#147 file-field-after-error.png16.12 KBbrankoc
#145 2113931-145.patch27.76 KBseanb
#131 File field uploaded.png46.47 KBekl1773
#131 Field Field loading.png39.86 KBekl1773
#131 File Field hover.png40.67 KBekl1773
#131 Field field after.png40.79 KBekl1773
#131 File field before 8.3.1.png39.79 KBekl1773
#131 Screen Shot 2017-04-28 at 1.41.37 PM.png104.73 KBekl1773
#126 interdiff-12003609-124-126.txt5.35 KBkatzilla
#126 file_field_design_update-2113931-126.patch28.82 KBkatzilla
#124 interdiff-121-124.txt1.42 KBgaurav.kapoor
#124 file_field_design_update-2113931-124.patch27.21 KBgaurav.kapoor
#121 interdiff-2113931-116-121.txt8.77 KBdaniel_rempe
#121 file_field_design_update-2113931-121.patch28.57 KBdaniel_rempe
#119 Screen Shot 2017-02-21 at 2.27.07 PM.png174.12 KBtkoleary
#116 Image Multi settings for Article.jpeg79.3 KBaaronchristian
#116 Image Multi settings for Article Drupal.jpeg47.96 KBaaronchristian
#116 file_field_design_update-2113931-116.patch27.68 KBaaronchristian
#112 file_field_design_update-2113931-112.diff30.2 KBaaronchristian
#108 file_field_design_update-2113931-108.patch24.57 KBaaronchristian
#106 jquery-throbber.mov151.1 KBtkoleary
#106 Screen Shot 2017-02-09 at 11.58.07 AM.png233.51 KBtkoleary
#106 Screen Shot 2017-02-09 at 11.57.26 AM.png166.38 KBtkoleary
#105 buttons.png6.97 KBAnonymous (not verified)
#105 layout.png15.48 KBAnonymous (not verified)
#105 remove.gif31.54 KBAnonymous (not verified)
#105 blinks.gif247.83 KBAnonymous (not verified)
#105 resize.png31.16 KBAnonymous (not verified)
#104 interdiff-2113931-98-104.txt917 bytesdaniel_rempe
#104 file_field_design_update-2113931-104.patch24.57 KBdaniel_rempe
#101 interdiff-2113931-87-98.txt11.79 KBdaniel_rempe
#99 multiple_files.png36.5 KBdaniel_rempe
#99 multiple_images.png72.55 KBdaniel_rempe
#99 files_upload.png14.47 KBdaniel_rempe
#99 file_upload.png9.71 KBdaniel_rempe
#98 file_field_design_update-2113931-98.patch24.65 KBdaniel_rempe
#94 Image settings for Article | drupal 8.3.x 2017-01-23 12-53-17.png70.36 KBgábor hojtsy
#94 Create Article | drupal 8.3.x 2017-01-23 12-55-07.png163.04 KBgábor hojtsy
#94 Create Article | drupal 8.3.x 2017-01-23 12-51-40.png105 KBgábor hojtsy
#87 2113931-87.patch20.36 KBdagmar
#87 interdiff-2113931-79-87.txt25.38 KBdagmar
#84 04-Add_File_Multiple-after.png117.62 KBkatzilla
#84 03-Add_File_Multiple-before.png107.86 KBkatzilla
#84 02-Add_File_Single-after.png103.32 KBkatzilla
#84 01-Add_File_Single-before.png100.3 KBkatzilla
#79 2113931-79.patch39.28 KBjofitz
#72 interdiff-68-72.txt0 bytesjoelpittet
#72 2113931-72.patch20.76 KBjoelpittet
#69 FileField.mov76.42 KBgábor hojtsy
#68 2113931-68.patch40.12 KBphenaproxima
#67 2113931-67.patch40.49 KBphenaproxima
#63 2113931-63.patch39.08 KBphenaproxima
#61 2113931-61.patch38.29 KBphenaproxima
#55 file_field_design_update-2113931-55.patch38.58 KBaaronchristian
#44 file_field_design_update-2113931-44.patch38.19 KBaaronchristian
#36 multi-value-image-field.png71.54 KByoroy
#29 interdiff.txt12.37 KBlauriii
#29 file_field_design_update-2113931-29.patch16.25 KBlauriii
#28 drop.gif164.35 KBjoelpittet
#27 file_field_design_update-2113931-27.patch12.23 KBlauriii
#10 seven-file-field-2113931-10.patch3.55 KBphilipz
#7 seven-file-field-2113931-6.patch68.87 KBlewisnyman
11.file-field.png70.09 KBlewisnyman

Comments

lewisnyman’s picture

Issue tags: +Usability, +styleguide

Tags

swentel’s picture

nod_’s picture

Issue tags: +JavaScript

clearly missing a tag

klonos’s picture

...moving related issues to their dedicated metadata section.

philipz’s picture

Is there any plan to push this forward?
I wonder if there's an issue somewhere to bring the drop file functionality into core by some library or custom solution? This surely needs to be done before any styling :)

But maybe it is too much for the scope of this issue and we should focus only on styling the current file field implementation using those mockups as style quide?

lewisnyman’s picture

Title: File Field style update » File Field design update
Component: Seven theme » file.module
Issue tags: +Seven
Related issues: +#1683838: Add HTML5 Drag & Drop upload to Field file

@philipz Yeah we should tackle it all here. The style doesn't make sense without the functionality. Changed the title of the issue slightly to cover this. #1683838: Add HTML5 Drag & Drop upload to Field file was closed as a duplicate of this issue.

Changing the component to the file module but tagging with Seven.

lewisnyman’s picture

StatusFileSize
new68.87 KB

I had a play around integrating the Dropzone library. The tricky thing with all these libraries it they all seem to want to control the upload process as well. It's nice but it makes it impossible to integrate with Drupal's AJAX system. I'm tempted to say the benefit of using an external library does not outweigh the cost of integrating.

Here's a patch anyway for the curious,

philipz’s picture

I'm trying to make it work with FileAPI only. The browser support seems OK but please let me know if this will be enough? FileAPI browser support.

lewisnyman’s picture

The support is fine, I'm not sure I get how FileAPI would help? We only want to add the interaction, we don't want to do anything with the file at all, just leave it up to the current behaviour.

philipz’s picture

StatusFileSize
new3.55 KB

Yes I understand that we want to use current behaviour where possible. So the only thing we want to do is adding drag&drop and without using external libraries like dropzone.js.
What I have tested so far is adding a behaviour using only event.dataTransfer property for drag and drop events witch is a part of File API.
The patch does not work though - the files are not being uploaded.

lewisnyman’s picture

Yeah, this seems to be a common issue with libraries that don't handle upload themselves. The file field is not writable. That explains why most libraries handle upload themselves.

This means we either:

  1. Rewrite how the filefield AJAX is handled so it doesn't go through the form (sounds scary)
  2. Make the file field input invisible and stretch it over the 'dropzone' and let browsers handle the drag and drop behaviour. I can't find a list of which browsers/operating systems actually support this though.
philipz’s picture

I wonder if we could try and use parts of Drag & Drop Upload module here. Looks like it does it without external libraries and yet using standard Drupal file upload.

klonos’s picture

@philipz: I was about to post a link to that project but you beat me to it.

Bojhan’s picture

Issue tags: +frontend
Bojhan’s picture

Status: Active » Needs review
Bojhan’s picture

Assigned: Unassigned » nod_

@nod_ could you take al ook at it?

The last submitted patch, 7: seven-file-field-2113931-6.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 10: seven-file-field-2113931-10.patch, failed testing.

dave reid’s picture

Issue tags: +Media Initiative
wim leers’s picture

Assigned: nod_ » Unassigned
Issue tags: +DrupalCamp Ghent 2014

Discussed this with @LewisNyman and @G-raph at DrupalCamp Ghent. @G-raph is very interested in taking this on. But @LewisNyman pointed out that the biggest stumbling block is likely going to be the integration with Drupal's AJAX system-based file uploads. Hence I proposed to handle that side of things, if @G-raph could handle the CSS and general JS side of things. Basically, @G-raph would do everything except for the Drupal.ajax stuff.

Hopefully we can get this moving forward again :)

rootwork’s picture

Curious if this ever got moving again :)

nod_’s picture

Make it look right, I'll make it work right.

I think we can make the JS work fairly easily with the approach in #10.

dave reid’s picture

Version: 8.0.x-dev » 8.1.x-dev

At this point I think this is 8.1.x material.

hass’s picture

Is this great new style available in a contrib module?

lauriii’s picture

Issue tags: -DrupalCamp Ghent 2014
lauriii’s picture

Assigned: Unassigned » lauriii
lauriii’s picture

Status: Needs work » Needs review
StatusFileSize
new12.23 KB

Now there should be working dropzone element with working add files button

joelpittet’s picture

Issue summary: View changes
StatusFileSize
new164.35 KB

Kinda sorta works:) Fun!

lauriii’s picture

StatusFileSize
new16.25 KB
new12.37 KB

Limited the functionality to file fields because image fields will be managed in #2115469: Image Field style update.

lauriii’s picture

One big questions I had was how are we going to integrate the multi field widget into this component because it has the drag handle. Anyone has ideas?

Status: Needs review » Needs work

The last submitted patch, 29: file_field_design_update-2113931-29.patch, failed testing.

lauriii’s picture

wim leers’s picture

Priority: Normal » Major

:O Great work, Lauri! This is a major usability improvement IMO.

yoroy’s picture

Yay @lauriii for working on this! Is your question in #30 about the code or the ui behaviour?

lauriii’s picture

@yoroy it is about the UI behaviour

yoroy’s picture

StatusFileSize
new71.54 KB

It would simply just work ;-)
Do you mean that there's no design for where the draggable thingy should be positioned?
That would need some design work indeed, current state is quite ugly:

lauriii’s picture

So there is a file component but it doesnt help much with the multi value field (with dragging). Just a notice that this issue is presumably mainly focusing on the file upload style instead of the image one which is again completely new story.

Bojhan’s picture

Lets move the [x] remove - next to the 4kb and then place the drag and drop at the far right.

aaronchristian’s picture

I've been working on this guy as an extension of lauriii's patch.

I'm having an issue installing uploadprogress.so for PHP 7.0, has anyone had any luck with this yet? I cannot find any guides on compiling the proper version. It seems like uploadprogress-1.0.3.1.tgz possibly is only supported up to 5.4?

droplet’s picture

Adding padding to file input is a clever way but we shouldn't do it. For example, IEs won't support it. Any browsers can take it off at anytime since it's not W3C standard.

DragEvent provided more info and more extendable. eg. we can prebuild thumbnails from client side.

aaronchristian’s picture

I've made some headway on getting this one towards a completed state. I just had a few notes I would love some feedback on;

1. The current design only accounts for an upload progression bar, however you need a 3rd party library (PECL upload progress or APC to be able to view this), in the majority of cases most users will be stuck with the existing throbber. Which currently, we don't have a UX pattern for.

2. Would it make sense to attempt to implement the HTML5 progress tag to replace the current upload progress structure of div's etc?

Thanks!

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

lauriii’s picture

@AaronChristian: Please post your progress here so you can get incremental reviews and other people can keep working and testing it!

One of the ideas for the throbber design I had was to replace the icon on the left with a throbber.

aaronchristian’s picture

StatusFileSize
new38.19 KB

Hey guys, sorry this took so long. I was having some issues with the patch, so hopefully this has all the changes. If it doesn't work let me know and I'll revisit making it.

Thanks!

jhedstrom’s picture

+++ b/core/themes/seven/js/dropzone.js
--- a/core/themes/seven/seven.libraries.yml
+++ b/core/themes/seven/seven.libraries.yml

Rather than put this in the Seven theme, wouldn't it make more sense to be in file.libraries.yml?

Similarly, rather than add this to the existing widget, might it make more sense to either provide a new widget for files, or make this a configurable option on the existing widgets?

mparker17’s picture

@AaronChristian, I wrote a blog article on my best practices for generating patches and interdiffs, which might help you in the future: http://openconcept.ca/blog/mparker/best-practices-generating-patches-and...

aaronchristian’s picture

Awesome thanks @mparker17, will have a read.

Cheers!

manjit.singh’s picture

Status: Needs work » Needs review

triggering the testbot for #44.

Status: Needs review » Needs work

The last submitted patch, 44: file_field_design_update-2113931-44.patch, failed testing.

aaronchristian’s picture

Thanks Manjit.Singh, I'm at little confused as to what has failed in the test. Are you able to point me to what the issue in my code is? I've never really worked on submitting and fixing patches before.

Thank you!

aaronchristian’s picture

@jhedstrom thank you as well. I'll leave that to someone else to comment, I just worked off of what was there originally. However I do like the idea of a toggle setting or something.

mparker17’s picture

@AaronChristian to find out what failed:

  1. look in the comment where you submitted your patch
  2. under your patch, you'll see one or more buttons that show the version of PHP and MySQL used, and how many failures (in the case of the patch from comment #44, it looks like PHP 5.5 & MySQL 5.5 18,509 pass, 2 fail
  3. click on the button. You'll go to a page (in the case of the patch from comment #44, https://www.drupal.org/pift-ci-job/232917) that shows you which test classes and which assertions in those classes failed
Fidelix’s picture

If you just scroll through the patch contents, you'll see that the contents are mangled.

I bet it is good but the patch file itself is broken.

mparker17’s picture

@Fidelix that's actually intentional: binary files get included in the diff to make it easier to review (see #1111224: Introduce .gitattributes to end the CRLF/LF and binary diff horror, and detect/auto-fix whitespace errors, #2166013: Remove macros from .gitattributes to avoid Git errors., https://www.drupal.org/node/1054616#comment-4994354 for background).

(previously, binary files didn't show up in patches, and we had to manually download them from the issue queue and place them in the correct place in the repository before reviewing or committing).

If you're having trouble applying the patch, and you're working with a clone of Drupal 8.2.x core, try applying it with git apply. Modern versions of patch(1) should also work; but if you're patching on Windows, you may need to pass --binary (I have not verified this though — see the patch(1) manpage for more information).

aaronchristian’s picture

StatusFileSize
new38.58 KB

Not sure if this fixes things as my simple test on my dev server keep throwing 500 batch errors. But perhaps we can get this tested again.

colan’s picture

Status: Needs work » Needs review

This status change should help. :)

Status: Needs review » Needs work

The last submitted patch, 55: file_field_design_update-2113931-55.patch, failed testing.

gábor hojtsy’s picture

Issue tags: -Media Initiative +D8Media

Retagging for the media initiative's current tag.

Bojhan’s picture

Assigned: lauriii » Unassigned
phenaproxima’s picture

Found some stuff -- mostly coding standards violations, but also a couple of bigger concerns...

  1. +++ b/core/modules/file/file.module
    @@ -1275,6 +1277,29 @@ function template_preprocess_file_link(&$variables) {
    +/**
    + * Gets a class for the icon for a MIME type.
    + *
    + * @param string $mime_type
    + *   A MIME type.
    + *
    + * @return string
    + *   A class associated with the file.
    + */
    

    This doc comment appears to be completely inaccurate...

  2. +++ b/core/modules/file/file.module
    @@ -1275,6 +1277,29 @@ function template_preprocess_file_link(&$variables) {
    +function file_shorten_filename($link_text) {
    +
    +  $name = $link_text;
    

    There's an extra line of white space here, and it seems like the argument should be $filename, not $link_text.

  3. +++ b/core/modules/file/file.module
    @@ -1275,6 +1277,29 @@ function template_preprocess_file_link(&$variables) {
    +  $nameWoExt = chop($name, '.' . $ext);
    +
    +  $nameStart = substr($nameWoExt, 0, 10);
    +  $nameEnd = substr($nameWoExt, -4, 4);
    

    This may be nitpicking, but can the variables use a consistent case? Core favors $name_without_ext, not $nameWoExt.

  4. +++ b/core/modules/file/src/Element/ManagedFile.php
    @@ -238,7 +238,7 @@ public static function processManagedFile(&$element, FormStateInterface $form_st
    +      '#attributes' => ['class' => ['upload-button js-hide']],
    

    This should probably an array with two elements: ['upload-button', 'js-hide']

  5. +++ b/core/themes/seven/css/components/dropzone.css
    @@ -0,0 +1,105 @@
    +.dropzone-buttons li {
    +  display: inline-block;
    +  margin-right: 10px;
    +}
    \ No newline at end of file
    

    Git needs a newline at the end of the file.

  6. +++ b/core/themes/seven/css/components/dropzone.css
    --- /dev/null
    +++ b/core/themes/seven/images/dropzone-new.png
    

    I wonder if these should be SVG, if possible, for flexibility's sake? (A side advantage is that the patch will not run afoul of Git's binary handling if it's using SVGs.)

  7. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,132 @@
    +  };
    +  ¶
    

    The blank line has extra whitespace that needs to be removed.

  8. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,132 @@
    +  if(Drupal.ajax) {
    +
    +    Drupal.Ajax.prototype.setProgressIndicatorThrobber = function () {
    

    Missing a space between if and (Drupal.ajax), and there's a needless blank line after it. It would also be nice if the setProgressIndicatorThrobber function had a doc comment to explain it.

  9. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,132 @@
    +      // move the throbber to the dropzone trigger
    

    s/move/Move

  10. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,132 @@
    +      //if($(this.element).hasClass('upload-button')) {
    +      //  console.log('uploaded');
    +      //} else if($(this.element).hasClass('remove-button')) {
    +      //  console.log('removed');
    +      //}
    

    Commented-out code blocks should be removed.

  11. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,132 @@
    +
    +    Drupal.Ajax.prototype.success = function (response, status) {
    +
    +      // Remove the progress element.
    

    It seems incredibly dangerous to overwrite the prototype of the AJAX success function. Surely there's got to be a better-encapsulated way of doing this?

  12. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,132 @@
    +      // Save element's ancestors tree so if the element is removed from the dom
    

    s/dom/DOM

  13. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,132 @@
    +      // we can try to refocus one of its parents. Using addBack reverse the
    +      // result array, meaning that index 0 is the highest parent in the hierarchy
    

    Why use addBack() to reverse an array? If memory serves, ES5 has Array.prototype.reverse(). And if we're trying to find the nearest [data-drupal-selector] element, is there any reason not to use $.closest()?

  14. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,132 @@
    +      // If the focus hasn't be changed by the ajax commands, try to refocus the
    

    s/ajax/AJAX

  15. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,132 @@
    +      if($(this.element).hasClass('upload-button')) {
    

    Needs a space after the word if.

  16. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,132 @@
    +        //console.log('uploaded');
    

    Commented-out debugging lines should be removed.

  17. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,132 @@
    +      } else if($(this.element).hasClass('remove-button')) {
    +        //console.log('removed');
    +      }
    

    This entire else if block can be removed.

  18. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,132 @@
    +      // move the throbber to the dropzone trigger
    

    s/move/Move

  19. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,132 @@
    +      if($(target).find('.image-preview').length) {
    

    Space after if.

  20. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,132 @@
    +})(jQuery, Drupal);
    +
    +
    

    Two extra blank lines here.

  21. +++ b/core/themes/seven/templates/form-element--managed-file.html.twig
    @@ -0,0 +1,105 @@
    +{#{{ kint(children) }}#}
    

    Should this be here?

phenaproxima’s picture

Status: Needs work » Needs review
StatusFileSize
new38.29 KB

Altered a few things in this patch (sorry for the lack of an interdiff, but I think binary data in the patch makes one impossible). And found a couple more things that give me pause...

  1. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,132 @@
    +      $dropzone.on('dragover mouseenter', function() {
    +        $(this).parents('.dropzone').find('.dropzone-trigger').addClass('is-hovering');
    +      });
    +
    +      $dropzone.on('dragleave mouseleave', function() {
    +        $(this).parents('.dropzone').find('.dropzone-trigger').removeClass('is-hovering');
    +      });
    

    This looks ripe to use $.on()'s event delegation...

  2. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,132 @@
    +      $('.js-upload-image').click(function(e) {
    +        $(this).closest('.js-form-item').find('input[type="file"]').click();
    +        e.preventDefault();
    +        e.stopPropagation();
    +      });
    

    A doc comment explaining this might be useful.

Status: Needs review » Needs work

The last submitted patch, 61: 2113931-61.patch, failed testing.

phenaproxima’s picture

Status: Needs work » Needs review
Issue tags: +Needs subsystem maintainer review
StatusFileSize
new39.08 KB

Yoooo! This one oughta pass the tests.

I think a JavaScript maintainer should take a good long look at the JavaScript parts of this patch before it can be RTBCed.

Status: Needs review » Needs work

The last submitted patch, 63: 2113931-63.patch, failed testing.

The last submitted patch, 63: 2113931-63.patch, failed testing.

nod_’s picture

  1. +++ b/core/modules/file/file.module
    @@ -1286,6 +1288,31 @@ function template_preprocess_file_link(&$variables) {
    +  $ext = pathinfo($filename, PATHINFO_EXTENSION);
    +
    +  $name = basename($filename, '.' . $ext);
    

    Since we're on PHP 5 > 5.2 we can use:

    $name = pathinfo($filename, PATHINFO_FILENAME); 
    

    Not sure of the need for this though.

  2. +++ b/core/modules/file/src/Element/ManagedFile.php
    @@ -238,7 +238,7 @@ public static function processManagedFile(&$element, FormStateInterface $form_st
    +      '#attributes' => ['class' => ['upload-button', 'js-hide']],
    
    @@ -255,6 +255,7 @@ public static function processManagedFile(&$element, FormStateInterface $form_st
    +      '#attributes' => ['class' => ['remove-button']],
    
    +++ b/core/themes/seven/templates/form-element--managed-file.html.twig
    @@ -0,0 +1,105 @@
    +        <ul class="dropzone-buttons">
    
    +++ b/core/themes/seven/templates/image-widget.html.twig
    @@ -0,0 +1,27 @@
    +    <div class="image-preview">
    

    js-hide is special but the rest of classnames that js uses should be data attributes. as in data-drupal-*

  3. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,109 @@
    +    attach: function (context, settings) {
    ...
    +    attach: function (context, settings) {
    

    Missing the detach function

  4. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,109 @@
    +        $(this).parents('.dropzone').find('.dropzone-trigger').addClass('is-hovering');
    ...
    +        $(this).parents('.dropzone').find('.dropzone-trigger').removeClass('is-hovering');
    

    Why not closest?

  5. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,109 @@
    +      $(context).find('.js-upload-image').click(function(e) {
    

    always use .on(), delegation or not. and when triggering an event, always use .trigger() when dealing with jquery objects.

  6. +++ b/core/themes/seven/js/dropzone.js
    @@ -0,0 +1,109 @@
    +    Drupal.Ajax.prototype.setProgressIndicatorThrobber = function () {
    ...
    +    Drupal.Ajax.prototype.success = function (response, status) {
    

    Ok, we can't do that in a theme. Maybe we need to move things around in ajax.js so that it's easily overridable in themes

    As far as I understand this it to change the place where the indicator is appended. Almost seems like we should create a new progress indicator type.

    The lesser evil would be to go through Drupal.ajax.instances and replace the success and indicator callbacks for the file upload field only, not everyone.

Some other issues: when I add a file and remove it. The next time I try to upload a file I get the file selector dialog twice, some attach/detach thing not going on. Maybe because the attach behaviors are missing .once() after element selectors.

I wouldn't necessarily delegate the mousz*/drag* event, since It's more costly to run it on the whole form than just the zone we're interested in.

When biding/unbinding event always add a namespace. here it could be dragleave.file-upload mouseleave.file-upload or something.

There are a few debug lines that needs to be removed too.

It's close, great stuff :) the handling of the progress indicator need some work to be cleaner.

phenaproxima’s picture

Status: Needs work » Needs review
StatusFileSize
new40.49 KB

Thank you, @nod_, for the review! I didn't address any of your comments in this patch because a) I don't quite grok the JS stuff it's trying to do, and b) I just want the damn tests to pass :)

I hate it when I say "this will pass the tests", and it epically fails. So I'm not going to say this one will pass.

phenaproxima’s picture

StatusFileSize
new40.12 KB

Made a few changes to the JavaScript -- mostly trying to get rid of the dodgy method overrides in Drupal.Ajax.prototype. No interdiff due to binary data.

gábor hojtsy’s picture

StatusFileSize
new76.42 KB

Other than some spacing snafus (once a file is uploaded, the elements are too close to the borders of the file field), this looks pretty good. Attached some video proof :) The "hover" state for the file dropzone is also not styled as designed. Those are the only things I found visually.

gábor hojtsy’s picture

Also the progress bar and remove elements are not implemented exactly as designed, but there was no design for a file field with extra elements either.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

joelpittet’s picture

StatusFileSize
new20.76 KB
new0 bytes

Tried to address the padding, made the button smaller(although the delete button could use a bunch more styling and a Seven preprocess hook)

Not sure how to deal with the preview image, it doesn't make sense to add it to the drop area because the size changes...

jonathanshaw’s picture

It looks like we've had the javascript maintainer review from @nod.

Overall it's very difficult to see from recent comments what work is still needed on this, hence needs IS update to clarify?

droplet’s picture

Just 2 cents.

I think it doesn't fulfill the IS and frontend code styles. We have to define a better HTML & CSS for it. e.g.:

1. Define a pattern.

Check it out the IS, we have 3 states: pre-upload -> uploading -> uploaded

<div class="dropzone">
    <div class="dropzone__preview">
        <!-- FILE FIELD -->
    </div>

    <div class="dropzone__container">
        <div class="dropzone__pre-upload">
            <div class="dropzone__actions">
                <button class="dropzone__add-files">Add File</button>
                <button class="dropzone__browse-libary">Browse Library</button>
                <button class="dropzone__other-button">Dropbox (Module Custom)</button>
            </div>
            <div class="dropzone__description"></div>
        </div>
        <div class="dropzone__progress is-uploading">
            <button class="dropzone__close">Close</button>
            <div class="dropzone__progress-filename">Uploading file-name</div>
            <div class="dropzone__progress-bar">
                <bar />
            </div>
            <div class="dropzone__progress-stat">Uploaded 2.6 of 4KB</div>
        </div>
        <div class="dropbox__uploaded">
            <div class="dropbox__uploaded-filename">interdiff--17.txt</div>
            <div class="dropbox__uploaded-stat">4KB</div>
            <button class="dropbox__uploaded-close">Close</button>
        </div>
    </div>
</div>

2. Sign off above pattern from frontend maintainers

3. Code & Add CSS3 Anime with basic JS

4. After real coding, sign off again from frontend maintainers, including the docs comments.

5. Sign off from UX/UE designers

6. Starting advanced JS work. (Pick a lib? Code our lib? Cross browsers testing and fixing..etc)

7. Sign off from JS maintainers

8. Happy Ending.

yoroy’s picture

Status: Needs review » Needs work
webchick’s picture

Issue tags: +sprint

This is coming up in the context of the Media library design at #2796001: [prototype] Create design for a Media Library. Adding to the current sprint; this looks incredibly close, and would be great to get it finished up for 8.3.

The last submitted patch, 72: 2113931-72.patch, failed testing.

jonathanshaw’s picture

Issue tags: +Needs reroll
jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new39.28 KB
tkoleary’s picture

Status: Needs review » Needs work
  1. +++ b/core/themes/seven/images/dropzone-new.png
    @@ -0,0 +1,219 @@
    +�PNG
    

    Looks like png code has been added here. There's two problems here; one, the image needs to be an SVG (for retina displays); and two, the image needs to be located in core/misc/icons in whichever directory matches it's hex color.

  2. +++ b/core/themes/seven/templates/form-element--managed-file.html.twig
    @@ -0,0 +1,105 @@
    +    <span class="field-prefix">{{ prefix }}</span>
    +  {% endif %}
    +  <div class="dropzone js-dropzone">
    +    <div class="dropzone-trigger"></div>
    +
    +    {{ children }}
    

    When I test this in the browser the image is loading into the same div as the upload button, not the area that contains the 'plus' image. I *think* the problem is in the nesting. Like the dropzone trigger div should wrap {{ children }}?

The rest of it is looking pretty good. I think it's getting close to done.

Bojhan’s picture

Very excited about this. Would this be novice changes?

katzilla’s picture

Assigned: Unassigned » katzilla
gábor hojtsy’s picture

Issue tags: +Berlin media sprint
katzilla’s picture

Assigned: katzilla » Unassigned
StatusFileSize
new100.3 KB
new103.32 KB
new107.86 KB
new117.62 KB

I have tested the latest patch against the media patch #151 here: https://www.drupal.org/node/2831274
as part of the Berlin media Sprint.

From what I see, it works already great with single file upload:


But for multiple file upload it still needs some work:
- the icon is missing for the uploaded files
- instead the icon is changed on the input for new file:


rajab natshah’s picture

I like this improvement.

andypost’s picture

would be great to get this in 8.3
looks only svg and dropzone issues left

dagmar’s picture

Status: Needs work » Needs review
StatusFileSize
new25.38 KB
new20.36 KB

Here is the image with the svg icons. I didn't find another example of an svg using sprites in core, should we pick one of the colors from the image to decide which folder use?

Also I found a small javascript console error when trying this patch (Uncaught TypeError: instance.element.hasClass is not a function), should be fixed now.

I couldn't fix #2 from #80.

Anonymous’s picture

+++ b/core/modules/file/file.module
@@ -1286,6 +1288,31 @@ function template_preprocess_file_link(&$variables) {
+    return substr($name, 0, $limit) . '...' . substr($name, -4) . '.' . $ext;
$limit = 10;
$name = "drupalrocks" (11)
$result = "drupalrock...ocks" ?

#87: It seems this patch lost a couple files as compared with #79 :)

Anonymous’s picture

And yet, substr not a good choice, because name can contain Unicode characters.
PS. How could I forget about it?! Because this is my first and forever light green issue on d.org :)

jonathanshaw’s picture

Status: Needs review » Needs work

NW for #88, #89 and #80.2

Anonymous’s picture

What about this:

use Drupal\Component\Utility\Unicode;

function file_shorten_filename($filename, $limit = 10, $ellipsis = '…') {
  $limit = (int) $limit;
  if ($limit < 1) {
    # throw new \InvalidArgumentException('Dude, give me more space! Regards, file_shorten_filename');
  }
  else {
    $name = pathinfo($filename, PATHINFO_FILENAME);
    if (Unicode::strlen($name) > $limit) {
      $left_part = Unicode::substr($name, 0, floor($limit / 2));
      $right_part = Unicode::substr($name, -ceil($limit / 2));
      $ext = pathinfo($filename, PATHINFO_EXTENSION);
      $filename = $left_part . $ellipsis . $right_part . '.' . $ext;
    }
  }
  return $filename;
}

Tests:

$name = 'drupalrocks.png';
$limits = [42, 10, 3, 1, 0, -1, 'lol'];
foreach ($limits as $limit){
  $result["$limit"] = file_shorten_filename($name, $limit);
}

# Output $result:
array (
  42 => 'drupalrocks.png',
  10 => 'drupa…rocks.png',
  3 => 'd…ks.png',
  1 => '…s.png',
  0 => 'drupalrocks.png',
  -1 => 'drupalrocks.png',
  lol => 'drupalrocks.png',
)

Changes:

  • Control $limit
  • special ellipsis symbol '…'
  • Unicode functions strlen & substr
  • magic '4' gone, now it just middle place
dagmar’s picture

#87: It seems this patch lost a couple files as compared with #79 :)

What do you mean? The patch file size is significantly smaller because there is no PNG there.

Anonymous’s picture

I'm mistake, sorry. Your patch great!

gábor hojtsy’s picture

Tested this again. The lack of padding in the single file scenario that I identified in #69 is still an issue. There was not design for image file uploads as to where the image thumbnail would be placed, so I think its fine for this patch to keep it in the box, but not without a padding :) Here is an up to date screenshot with the latest patch:

The multifile scenario does not look like at all as designed, the uploaded file does not show up as a small bordered item, but I think we can go step by step on this and ALSO the image variant of this was not designed and IMHO it would be sad to wait for that to happen for any improvement:

Where this is used as the default file widget (field settings), the Add files button is still displayed but of course does not work anymore. (The same button is removed when interacting with this widget on the entity form itself, so this does not appear there):

Finally the button says "Add files" even if the field is limited to one file. This problem applies to both the field settings and the entity edit form itself.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

katzilla’s picture

Assigned: Unassigned » katzilla

Working on this issue on global sprint weekend.

webflo’s picture

daniel_rempe’s picture

Status: Needs work » Needs review
StatusFileSize
new24.65 KB

Worked on this in pairprogramming with @katzilla. Current patch implements most parts of the given design. There are still some responsive issues in draggable table on multi value fields. The designed progressbar is not possible to implement at the moment due to a not functional implementation of uploadprogress for php7.

daniel_rempe’s picture

StatusFileSize
new9.71 KB
new14.47 KB
new72.55 KB
new36.5 KB

Added some screenshots to give an impression of the developent in #98.

Single file upload:
file upload

Multiple file upload:
files upload

Multiple images:
multiple images

Multiple files:
multiple files

jonathanshaw’s picture

An interdiff for #98 would help reviewers.

daniel_rempe’s picture

StatusFileSize
new11.79 KB

Here is the interdiff for #98.

jonathanshaw’s picture

+++ b/core/modules/file/src/Element/ManagedFile.php
@@ -181,11 +181,11 @@ public static function uploadAjaxCallback(&$form, FormStateInterface &$form_stat
+      $form[$current_file_count]['#attributes']['class'][] = 'ajax-new-content managed-file';

I think this should be:

$form[$current_file_count]['#attributes']['class'][] = 'ajax-new-content';
$form[$current_file_count]['#attributes']['class'][] = 'managed-file';
daniel_rempe’s picture

You are right. The classes should be implemented as array values. I am going to upload a modified patch tomorrow. Thanks for your review so far.

daniel_rempe’s picture

Here is the patch from #98 including the remarks from #102.

Anonymous’s picture

StatusFileSize
new31.16 KB
new247.83 KB
new31.54 KB
new15.48 KB
new6.97 KB

Nice work! A couple additions to the test:

  1. inflexible resize after adding image (see resize.png)
  2. blinking when drags images, especially from top left corner (see blinks.gif)
  3. 'remove' label appears suddenly (see remove.gif)
  4. layout for image has gaps (see layout.png)
  5. we have two hidden ("Choose file", "Upload") and one vissible ("Add file") buttons, we need all it? (see buttons.png)
  6. and yet, a changes between #29 and #44 are not quite obvious). For example, the appearance file_shorten_filename(). We really need it now? (if yes, see #91)
tkoleary’s picture

Issue summary: View changes
Status: Needs review » Needs work
StatusFileSize
new166.38 KB
new233.51 KB
new151.1 KB

@Daniel_Rempe

This is coming together nicely. Just a couple of minor things I noticed.

1. The jquery ajax throbber should really appear *inside* the area where the drop icon is and not *push* the button and text over as it currently does.

See quicktime movie: https://www.drupal.org/files/issues/jquery-throbber.mov

On multiple file upload the asterisk indicating tabledrag has happened is reflowing oddly.


aaronchristian’s picture

Hey all, I have a patch that will fix the issues noted in comments #105 & #106.

Will post tomorrow morning once I get back into work.

Thanks!

aaronchristian’s picture

StatusFileSize
new24.57 KB

Here she be.

Should note: I've added RTL support as well.

aaronchristian’s picture

Status: Needs work » Needs review
Anonymous’s picture

@AaronChristian, it seems this is a copy of #104 patch.

slashrsm’s picture

Status: Needs review » Needs work

Correct:

➜  /tmp  diff file_field_design_update-2113931-104.patch file_field_design_update-2113931-108.patch
➜  /tmp  
aaronchristian’s picture

StatusFileSize
new30.2 KB

Ahhhh crap, I attached the wrong patch file, not sure what happened there. This ones legit though.

aaronchristian’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 112: file_field_design_update-2113931-112.diff, failed testing.

aaronchristian’s picture

Ahh i believe this is failing due to the tabledrag changed (*) being moved within the handler instead of the cell (@tkoleary - fixes the reflowing of the asterik).

I'll have a deeper look into this.

aaronchristian’s picture

Okay think I found the issue.

One thing that still needs some attention is the default image settings page. That form has a bit of a different layout, wondering if we can force the same sort of layout as we have on a single image upload field.

aaronchristian’s picture

Status: Needs work » Needs review
tkoleary’s picture

@ AaronChristian

Lots of improvement here. As noted in UX meeting the only things I saw in simplytest were:

  1. The button only works first time, but the plus icon works all the time
  2. When the throbber appears it is on top of the icon, instead the icon should be hidden when the throbber is there.
  3. In narrower screens the description field overflows the parent containter
tkoleary’s picture

Issue summary: View changes
StatusFileSize
new174.12 KB

@AaronChristian

One more thing. When adding with multi value, for some reason it goes back to the other icon on the third upload. Weird.

katzilla’s picture

Issue tags: +DevDaysSeville
daniel_rempe’s picture

@katzilla and I worked on this a little bit more.
We removed the background image when the throbber is shown and realigned the alt and title input fields.

Status: Needs review » Needs work

The last submitted patch, 121: file_field_design_update-2113931-121.patch, failed testing.

tkoleary’s picture

@Daniel_Rempe

Looks much better.

Still have the wrong icon on multi-value fields though.

gaurav.kapoor’s picture

Status: Needs work » Needs review
StatusFileSize
new27.21 KB
new1.42 KB

Status: Needs review » Needs work

The last submitted patch, 124: file_field_design_update-2113931-124.patch, failed testing.

katzilla’s picture

Fixed the coding standard issues and proposed a solution for the table on mobile. In some cases (when the display option of the file-field is activated, or when 'show row weights' is active on multi-value fields) there is too much content in the table, so it gets messy. We added an overflow, so that one can scroll the table.
We also fixed the issue with the wrong icon on multi-value-fields. Please test and provide feedback.

katzilla’s picture

Status: Needs work » Needs review
daniel_rempe’s picture

As we just discussed with @ifrik we should open a separate issue for all mobile display problems and try to get this in for 8.4 since this is already a long list of comments. We opened the issue here https://www.drupal.org/node/2863808

jonathanshaw’s picture

Review points made since #98 that have not been explcitly mentioned as having been addressed:
#116 default image settings page
#118.1

I've updated the IS to reflect
#98: "The designed progressbar is not possible to implement at the moment due to a not functional implementation of uploadprogress for php7." (and created a follow-up #2863846: File Field design update progress bar)
#128 "separate issue for all mobile display problems" #2863808: File Field design update mobile specific table issue

colan’s picture

If anyone's looking for something to work on at the DrupalCon sprint, I'd recommend this issue. Won't be there myself though. (I'd work on this myself, but I'm best kept away from anything front-end related.)

ekl1773’s picture

Here's a review of where things stand- I looked at a clean install of 8.4 for the "before" screenshot, then applied the most recent patch (#126) for the "after" screenshots. Further details below are outstanding issues from ~#106 onwards. Hope this is helpful!

Before:
before
After:
After
Hover:
Hover
Loading:
Loading
Uploaded:
Uploaded

#116, the remove button is next to the uploaded image thumbnail for the default image field settings page but not for a file upload field on an Add Content page. Also, the layout should be updated so the alt and title fields are *inside* the box with the uploader.
#118, throbber still appears next to icon on default image field settings page rather than on the icon

Also attch, this is what happens when you try to upload an image to an unlimited image field that already has a default image/file defined... this seems confusing, maybe the default image could be labeled? should it appear there?
image field screenshot

aaronchristian’s picture

Awesome thank you so much Elli. I'll review all your feedback as soon as I get back to my work place.

Safe travels home.

nithinkolekar’s picture

I can see alternative text is mandatory now , so could be possible to place filename as default alternative text ? this could save some time.

rootwork’s picture

@nithinkolekar Using the filename as alternative text is an antipattern. WordPress actually removed this functionality late last year for accessibility reasons.

Other references:

Bojhan’s picture

Did #123 get a fix? It looks like all other followups are filed.

@rootwork Thanks, that's correct - we won't do that and/or introduce that in this patch.

What is left for RTBC?

jonathanshaw’s picture

@Bojhan see #131

chr.fritsch’s picture

Assigned: katzilla » Unassigned
dubcanada’s picture

Assigned: Unassigned » dubcanada

I will finish this up.

Is there an image icon we could use rather then a file icon, for images?

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

aaronchristian’s picture

@dubcanada, at this time, no. Just due to the flexibility of the file field being able to accommodate different types, not just images and files. Contrib can add different types of widgets to the file field.

dubcanada’s picture

The whole multiple files/images needs to be rethought I'm going to take a few days and play around with it and see what I can come up with. It doesn't make much sense right now.

chr.fritsch’s picture

Assigned: dubcanada » Unassigned
webchick’s picture

Status: Needs review » Postponed

Given we added Media to 8.4.0, and it's still not visible in the UI until the whack of issues under "Required before the module is shown through the UI" is done: #2825215: Media initiative: Roadmap I think it's a good idea to minimize the amount of change happening in the File/Image modules. Therefore, postponing this on the other issue, per the UX team.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

seanb’s picture

StatusFileSize
new27.76 KB

Just a reroll for 8.6. I'm not sure if this should really be postponed for the media module. The media module uses file/image fields so it would benefit from this change as well.

tacituseu’s picture

brankoc’s picture

After testing in Firefox Win/58 and Chrome Win/64 I found a number of additional issues.

1) When I applied the latest patch, the script inclusion line ('js/dropzone.js: {}', seven.libraries.yml in the Seven theme folder) received one level of indentation too much, so that Drupal thought it was a stylesheet. I haven't seen anyone else complain about this, so this might just be my problem.

2) Field labels are absent. This is most noticeable on fields for uploading single images/files, because for fields for multiple/unlimited images/files the summary serves as a sort of label.

This behaviour cannot be influenced through the Manage Form Display tab of the content type.

Presumably this should be fixed in core/themes/seven/templates/form-element--managed-file.html.twig.

Is there any reason why labels were left out of the template?

How is this handled for other types of fields? Is the general implementation that the label is derived from the label sub-field, or does this differ per field?

3) When uploading multiple files/images of which one has the wrong extension, a completely different interface is shown for the valid files. (See illustrations.)

If you select and then delete one of the valid files/images, the system deletes all of the files/images from that particular upload, after which the new upload interface is restored.

Illustration: one valid upload and one invalid upload, pdf1.pdf in a field that doesn't allow PDFs.
[screenshot]

Illustration: for contrast, an upload with only valid file name extensions.
[screenshot]

4) Alt and title fields for single images break out of their container on narrow screens. (See illustration.)

This is related to the bug reported in #118.3, which was reported fixed in #126.

[screenshot]

5) The current dropzone implementation does not degrade gracefully when Javascript is disabled for whichever reason. (See illustration.)

[screenshot]

If a user has Javascript disabled, instead of falling back to the default browser interface (which works fine), the dropzone partially replaces that interface, leading to problems:

a. The dropzone is still shown, but should be hidden.

b. The Upload button is shown (correctly), but does not work.

c. A fake Add Files button is shown, but doesn't work.

Part of the problem is that some of the HTML necessary for creating the dropzone is generated through the template rather than using Javascript. Instead, we should use the additional technology (Javascript) to generate and add (to the DOM) the HTML that is required by the additional technology. We could use data attributes to pass information from the CMS to the additional technology.

999) [notabug] Furthermore, in reply to #129, I cannot replicate the issue from #118.1 ("The button only works first time, but the plus icon works all the time."), so I assume it has been fixed. I haven't ran any tests though (I wouldn't know which specific tests to run), I just tried it out in two browsers. I could click the Add Files button multiple times and it worked every time.

brankoc’s picture

StatusFileSize
new28.71 KB
new7.82 KB

This fixes the following issues for the default image in the field settings edit screen (comment #131):
- correct styling remove button.
- correct styling throbber for remove button.
- correct styling upload throbber.

This makes sure alt and title fields for single images do not break out of their container on narrow screens (comment #147.4). (UPDATE: fixed comment number)

https://www.drupal.org/files/issues/2113931-148.patch

https://www.drupal.org/files/issues/interdiff-145-148_2.txt

jonathanshaw’s picture

Great, so if I'm understanding right we now have outstanding:

#131

"Also attch, this is what happens when you try to upload an image to an unlimited image field that already has a default image/file defined... this seems confusing, maybe the default image could be labeled? should it appear there?"

and
#147.1, #147.2, #147.3, #147.5.

(#148 is wrong when it say it addresses #147.2 it means #147.4)

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

phenaproxima’s picture

Status: Postponed » Needs review
Issue tags: -D8Media +Media Initiative

Since @webchick postponed this a year ago, a number of things have changed. The experimental Media Library module provides a vastly improved UI that does not interfere with the work in this issue and would in fact benefit from it. So let's unblock this and continue.

The last submitted patch, 145: 2113931-145.patch, failed testing. View results

jonathanshaw’s picture

Issue tags: +Needs reroll
vacho’s picture

StatusFileSize
new28.84 KB

Patch rerolled

vacho’s picture

Issue tags: -Needs reroll

Status: Needs review » Needs work

The last submitted patch, 154: 2113931-154.patch, failed testing. View results

vacho’s picture

I don't understand how to reply testing problems for patch #154, in local there are another testing problems.

seanb’s picture

Status: Needs work » Needs review
StatusFileSize
new36.39 KB
new39.41 KB

Attached is a new patch implementing the following changes:

  • Fixed all styling issues:
    • RTL
    • IE11
    • Image field
    • Table view
  • Added progressive enhancement via JS instead of through template files. When you don't have JS enabled the regular file field is shown.
  • Refactored CSS since the HTML was slightly changed and some of the styling improvements were not directly related to the dropzone. The managed file improvements are in a separate CSS file.
  • Added ES6 file for the JS.

There are still some mobile responsive issues for the table. We have #2863808: File Field design update mobile specific table issue for that.

Please review.

Status: Needs review » Needs work

The last submitted patch, 158: 2113931-158.patch, failed testing. View results

seanb’s picture

Adding screenshots for the latest patch to the IS for easier review.

seanb’s picture

Status: Needs work » Needs review
StatusFileSize
new37.46 KB
new1.07 KB

This should fix the test.

seanb’s picture

StatusFileSize
new37.33 KB
new509 bytes

Ahhh, remove some CSS that shouldn't be there. Sorry about that!

The last submitted patch, 161: 2113931-161.patch, failed testing. View results

brankoc’s picture

Status: Needs review » Needs work

Good busy.

"default-image-uploaded-no-js.png"

This screenshot appears to be empty.

brankoc’s picture

Tested Firefox/Win 64.0

Review of patch 162.

a. Should the remove button activate on right-click? It does now. Is this even a problem for this issue? Mouse button handling for removing files appears to be taken care of elsewhere.

b. The shorten filename function lengthens some filenames and also sometimes repeats characters.

Examples (top becomes bottom):

1234567890abcdef
          ^     ^
1234567890abcdef

1234567890abcdefgh
          ^
1234567890...efgh

1234567890abc
          ^
1234567890...0abc

Patch attached.

c. The Unicode patch from comment #91 does not seem to have made it into actual patches.

d. The description/help list can be added to in the content type settings and by using hooks. I have added a few screenshots of how it looks like when a largish text is added.

Example of a large help text.

Example of  a help text on an uploaded file.

Example of help text on an uploaded image.

seanb’s picture

Status: Needs work » Needs review
StatusFileSize
new37.69 KB
new9.19 KB

Thanks Branko! Let's fix it.

A. The buttons works with the jQuery mousedown event as do all AJAX buttons. I think fixing this is out of scope for this issue.
B./C. Nice find. The unicode methods are deprecated in favor of mb_strlen and mb_substr, but I did adopt the proposed changes from #91 since I think that method seems to be a better implementation. Updated the failing test accordingly.
D. Fixed. Had to add some JS to pull the preview image for the single image widget to another wrapper to make it work. The HTML is not optimal for this specific case. Changing it through a template changes the HTML for all other cases as well. This felt like the lesser evil.

Please review!

brankoc’s picture

StatusFileSize
new1.87 KB

I came across the following issues in patch 166:

1) A single uploaded file displays a cropped icon if the managed form item only contains the file name and no additional fields. (See illustration.)

2) The title of the Display column in a managed file table is cropped in some browsers and may also get cropped when translated. My solution is to not assume a width for that column. (See illustration.)

3) On very narrow screens, forms.css adds a top margin to the Remove button.

4) The Remove button is positioned slightly too high. This is only really noticeable in the managed form element for a single uploaded file. (See illustration.)

5) If I add a line-break in the Help text field of a field's definintion (/admin/structure/types etc.), this gets displayed as the HTML character entity reference for carriage return in the node edit form's description. I assume this is a problem outside the scope of the current issue. (See illustration.)

6) When I upload too many images (for example 6) to a Limited image field with 5 slots, only five images are uploaded and I get an error message: "Field MACHINE_READABLE_NAME can only hold 5 values but there were 6 uploaded. The following files have been omitted as a result: NNN.ext." This field will be available to users who may not recognise the machine readable name. Should this perhaps be the human readable name?

7) When I upload too many images to a Limited image field with 1 slot, the upload fails without an error message. Should this not work the same as a limited field with multiple values, i.e. upload what you can and give an error message for the rest?

Then there is one minor issue that is a hill I do not wish to die on, but that I wanted to mention nevertheless:

8) The file name shortener still lengthens file names. However, with a proportional font this is barely noticeable because the default ellipsis (three dots) is narrow. Also, it does exactly what it says in the comment ("The maximum number of characters to show from the original string"), so in that sense the function works as advertised.

It is just a bit odd that the function is called file_shorten_filename() when it sometimes lengthens filenames.

Examples for the default limit (10 characters):

1234567890a.txt (base name $limit + 1 characters long)
1234567890ab.txt (base name $limit + 2 characters long)
1234567890abc.txt (base name $limit + 3 characters long)

These become:

12345...7890a.txt (new base name $limit + 3 characters long)
12345...890ab.txt (new base name $limit + 3 characters long)
12345...90abc.txt (new base name $limit + 3 characters long)

The attached patch solves issues #167.1, #167.2, #167.3 and #167.4.

brankoc’s picture

Hm, I was sure I had added all files. Anyway, here are the three illustrations (two issues share a screenshot) plus the patch.

The related interdiff is in #167.

[Width of display column]

[cropped icon]

[carriage return displayed]

seanb’s picture

StatusFileSize
new30.52 KB
new17.07 KB

Thanks for the new patch and testing so thoroughly @brankoc! Some more updates:
167.1 Added a min height.
167.2 I think that's a good solution, thanks!
167.3 Looks good!
167.4 Looks good!
167.5 This is out of scope for this patch and I think that is supposed to happen.
167.6 I think this is also out of scope for this patch.
167.7 Fixed. Dragging multiple files into a single file field is supposed to be block before upload. I removed the JS that broke that.
167.8 The filename shortening was added in #44 but was not part of the original design or issue. Since this is probably an accessibility/usability issue, and also leading to lots of other discussions, I removed the code from the patch.

Besides that I changed the following:

  • Vertically centered image/icon for single file/image fields to show where the dropzone icon is.
  • Aligned multi upload field table elements.
  • Stopped filenames from breaking out of their container.
  • The custom success callback for the dropzone file uploads seemed to be equal to Drupal.Ajax.prototype.success, so I removed that.
jonathanshaw’s picture

@seanB could you tell us what items if any from #149 are outstanding?

seanb’s picture

Regarding #149:

#131 There is no design for how / where to show a default image for a field. In the latest patch the image is shown on top of the dropzone. So this is a challenge.

#147.1 Fixed.
#147.2 Fixed.
#147.3 Still an issue.
##14.4 Fixed.
#147.5 Fixed.

So I guess what is still todo:
#131: Figure out how to display a default image in the new design
#147.3: Fix the display after multiple uploads with some invalid files

seanb’s picture

Just looked at the final 2 things.
#147.3 Seems to be an existing core issue. Created #3027386: FileWidget for multivalue field is displayed incorrectly when some of the uploaded files are invalid for this.

#131: Decided to add the default image to the description with a label 'Default image'. I think the description is probably where this belongs. Besides that, before the default image didn't have a label, which could be unclear to editors. I think adding this label makes sense.

Also removed some CSS we don't need.

Screenshots of the default image change
Before with JS.
Before screenshot

After with JS.
After screenshot

Before without JS (where the change has the biggest impact).
Before screenshot (no JS)

After without JS.
After screenshot (no JS)

brankoc’s picture

As SeanB can patch faster than I can review, here is my review without a patch. :-)

1) Before patch #171, a preview for the default image would be shown for unlimited, limited single and limited multiple image fields. After application of patch #171, I only get a preview image for a limited, single image field.

2) A single, managed file has its description flowing underneath the file icon. See screenshot. This was introduced in #169.

[screenshot]

(Edited to clarify that the preview was of the default image.)

jonathanshaw’s picture

@brankoc do you think could make a list of all the permutations/scenarios we need to manually test with each patch? There seem to be so many that it would be easy to forget some!

brankoc’s picture

I had a list somewhere, but I think I threw it out. Anyway, it should not be too hard to restore:

1) With/without Javascript.
2) With/without CSS.
3) 1 / N / unlimited files.
4) Image field / file field.
5) node edit form / field settings form.
6) empty field / field with uploads.
7) On narrow/wide screens.

And then there are various field settings you can enable that will modify the appearance of the field in the form:
10) With help text / without help text.
11) Required field / not required field.
12) With / without default image.
13) With / without Alt field (Image).
14) With / without Title field (Image).
15) With / without Description field (File).
16) With / without Display field (File).

I think I originally tested for 1/N/unlimited values, because I wanted to add the "Upload up to N files - M remaining" line, but then I reconsidered. I wasn't sure if that should be part of Seven, maybe something on the level of the File or Field module should first expose a remaining value. I noticed that Media has been working on 'remaining', but I haven't checked what they have done so far.

By the way, I just saw that the default image can be set both in the Edit and in the Field Settings tab of the field settings, why is that?

If the dropbox is added and an image field has a default image, that default image (or at least its filename) is shown on the Edit tab of the field settings, but not on the Field Settings tab. (Which I guess makes sense in a way, because the contents of the Field Settings tab is supposed to be set in stone once the field is in use.)

seanb’s picture

StatusFileSize
new32.07 KB
new2.51 KB
new783.56 KB
new1.25 MB

By the way, I just saw that the default image can be set both in the Edit and in the Field Settings tab of the field settings, why is that?

I believe 1 is a global settings for the field (in field storage) and the other is only for the field instance (at least according to the form).

Thanks again for the review!

#173.1 Fixed. At least I think you meant the default image?
#173.2 Fixed.

Empty fields now look like this:
Empty file/image fields

Filled fields now look like this:
Filled file/image fields

brankoc’s picture

I have looked at #176 and have found no additional problems to the ones already documented in separate issues.

#176 solves #173.

#173.1 Fixed. At least I think you meant the default image?

Correct.

I have edited the text of #173.1 to reflect this.

I have also added the narrow/wide scenario to #175.

brankoc’s picture

Status: Needs review » Reviewed & tested by the community
lauriii’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
StatusFileSize
new227.94 KB
new38.51 KB
new6.26 KB
new47.38 KB

I'm sorry if I missed something because I didn't read all the comments on this issue.


  1. The implementation is still quite far from the design. The design doesn't include the table headers. Each of the rows should have borders one very side of the element, and few pixels of margin between them.

  2. I can't find the "Add a new file" label in the designs as well so it probably should be removed.

  3. The designs show "remove" text on the button when hovered which is missing from the implementation.

  4. List of files is still quite different from the designs as well.
  5. +++ b/core/modules/file/src/Element/ManagedFile.php
    @@ -243,7 +243,7 @@ public static function processManagedFile(&$element, FormStateInterface $form_st
    +      '#attributes' => ['class' => ['upload-button', 'js-hide']],
    
    @@ -260,6 +260,7 @@ public static function processManagedFile(&$element, FormStateInterface $form_st
    +      '#attributes' => ['class' => ['remove-button']],
    

    Could we add these classes in Seven instead?

  6. +++ b/core/themes/seven/css/components/dropzone.css
    @@ -0,0 +1,176 @@
    +.dropzone .dropzone-trigger {
    ...
    +[dir="rtl"] .dropzone .dropzone-trigger {
    
    +++ b/core/themes/seven/js/dropzone.es6.js
    @@ -0,0 +1,131 @@
    +            <div class="dropzone-trigger"></div>
    

    This could be changed to dropzone__trigger

  7. +++ b/core/themes/seven/css/components/dropzone.css
    @@ -0,0 +1,176 @@
    +.dropzone .dropzone-no-trigger .js-dropzone-add-button {
    ...
    +.dropzone .dropzone-no-trigger .js-dropzone-add-button:before {
    ...
    +.dropzone .dropzone-no-trigger .description {
    ...
    +.dropzone .dropzone-no-trigger .description li {
    ...
    +.dropzone .dropzone-no-trigger .description li:after {
    ...
    +.dropzone .dropzone-no-trigger .description li:last-child:after {
    ...
    +.dropzone .dropzone-no-trigger .image-preview {
    ...
    +.dropzone .dropzone-no-trigger .messages {
    
    +++ b/core/themes/seven/js/dropzone.es6.js
    @@ -0,0 +1,131 @@
    +            <div class="dropzone-no-trigger">
    

    This should be changed into dropzone__no-trigger

  8. +++ b/core/themes/seven/css/components/managed-file.css
    @@ -0,0 +1,136 @@
    +#edit-settings-default-image .form-managed-file-wrapper.dropzone-enabled.has-file {
    ...
    +#edit-settings-default-image .form-managed-file-wrapper.dropzone-enabled.has-file .description {
    

    Maybe we could add a class instead to this element so we could avoid using the id in the selector?

  9. +++ b/core/themes/seven/js/dropzone.es6.js
    @@ -0,0 +1,131 @@
    +        .find('.form-managed-file-wrapper')
    ...
    +              .find('> .description')
    +              .appendTo($('.image-widget-data', this));
    ...
    +          const $wrapper = $(this).parents('.form-managed-file-wrapper');
    ...
    +              element.hasClass('upload-button') &&
    

    Could we add a js- prefixed class to these elements as well?

  10. +++ b/core/themes/seven/js/dropzone.es6.js
    @@ -0,0 +1,131 @@
    +          if ($(this).hasClass('has-file')) {
    

    Maybe this should be converted into a data attribute?

skaught’s picture

re:#45

Even though attention is toward cleaning up the admin ui..I also might think that js/css might be better to move to a more common space as other contrib and custom themes and modules will need to have access to it's basic layouts and js integration.

if not file.libraries.yml as suggested, then within classy.

skaught’s picture

StatusFileSize
new4.67 KB
new3.52 KB

this moved assets and attaches to the render of the file element. no other points addressed.

seanb’s picture

Status: Needs work » Needs review
StatusFileSize
new15.44 KB
new33.66 KB

Thanks @lauriii.

#179.1. Kind of missed that in the IS, but now I'm looking at the design example I can kind of see why. I think we should probably talk about the UX and a11y implications of this. The fact that a multiple file field is in a details element make it easier for users to see which file belong to which field. The table headers are also important when you show the weight field and display checkbox. The tabledrag icon is also not in the design and is a very important feature. I think the multiple file field table needs to be designed with all available elements and probably discussed with the UX and accessibility teams. Since this issue has become complicated enough already, it might be more suited for a followup?

#179.2. Fixed.

#179.3. Fixed.

#179.4. Same as point 1. I will try to at least get UX feedback in the meeting tomorrow.

#179.5. We could, but that would mean we have to implement like 4 different preprocessors. I think this is the most consitent way to add it, and this way other themes or modules can use these classes as well. An alternative would be to use a .js-form-submit[name$='_remove_button'], but I think what we currently have is the best option.

#179.6. Fixed.

#179.7. Fixed.

#179.8. Fixed, we actually didn't need that anymore.

#179.9. Fixed.

#179.10. We are using this mostly for styling purposes. We could add both, but I'm not sure if that is actually a better solution?

Regarding #180 / #181:
Unfortunately moving this JS and CSS to stable (or the file module) could potentially break existing sites. I'm pretty sure we can't do that.

skaught’s picture

i'm unsure how adding the dropzone js/css could break existing sites anymore or less than adding it to only to the admin theme.. it is progressive enhancement.

brankoc’s picture

Status: Needs review » Reviewed & tested by the community

Re #179.1, earlier discussion about the discrepancy between the visual/UX design and the implementation of the file widget for multiple files took place in #30, #34, #35, #36, #37, #38, #94 and #141.

brankoc’s picture

Status: Reviewed & tested by the community » Needs review

Sorry, did not mean to reset the Status.

The last submitted patch, 181: 2113931-181.patch, failed testing. View results

lauriii’s picture

As you @seanB said, we should ask for input from the UX team related to #179.1 and #179.4. Since this is already a pretty impressive improvement, I would be +1 for committing this issue with a scope that is close to what has been done so far and work on rest of the improvements in a follow-up. In any case, I think we should consult the UX team first and see what they think.

Related to #180; In my opinion, it would be great if we could make some improvements to Classy using the changes made here. However, I don't think that should be done in the scope of this issue.

seanb’s picture

i'm unsure how adding the dropzone js/css could break existing sites anymore or less than adding it to only to the admin theme.. it is progressive enhancement.

When a custom theme is built on top of stable/classy for example, and we add the JS/CSS from this issue to those themes (or the file module), the markup and base CSS for the custom frontend theme changes. Custom themes could have custom CSS for managed file fields, and that CSS could conflict with the default styles we are adding, causing frontend forms to look different.
Drupal 8 considered the stable and classy themes to be part of the public API, which means they have to be backwards compatible. The seven theme is internal, so that means we are allowed to change it as per https://www.drupal.org/core/d8-frontend-bc-policy

So even though I think it would be great to improve this for everyone, we probably can't do this until Drupal 9.

seanb’s picture

I just demoed this in the weekly UX call. The general feedback on the actual upload field was positive. A couple of things were mentioned.

The default image is currently not designed for the single/multiple fields. Showing it in the description is probably not the best looking solution. This needs additional design work and we already have an issue to improve the image fields as well (#2115469: Image Field style update).

The multiple file field design has several issues. This also needs additional design work and should be fixed in a followup (#3029340: File Field design update: Multiple file fields).

  • The table header is important for the cases where you have multiple columns, like the weight field and the display checkbox. We probably can't remove that.
  • The tabledrag is missing, this feature is important and should be incorporated in the design.
  • The 'Show row weights' link is missing as well.
  • When adding multiple files, the label and the upload field are quite far apart. We need a way to show users where a field starts and where the field ends.
seanb’s picture

Title: File Field design update » File Field design update: Upload field.
Issue summary: View changes
Issue tags: -Needs issue summary update
seanb’s picture

Issue summary: View changes
StatusFileSize
new712.51 KB
new1.22 MB
new7.78 KB
new33.46 KB

Found some minor issues while working on this:

  1. Moved the default image to the right side of the new widget since that looks a lot better and is closer to the original. Let's keep #2115469: Image Field style update to improve this some more.
  2. Found a missing padding on image previews.
  3. Changed the way the 'Add a new file' text is hidden (should be done in Seven, and only visually hidden for accessibility), thanks @brankoc for pointing that out.
  4. Added a required attribute to the details element since we are not showing the field label with the upload field for fields with cardinality > 1.
  5. Updated the screenshots in the IS
seanb’s picture

Issue summary: View changes

.

lauriii’s picture

StatusFileSize
new32.87 KB
new4.36 KB

I tried to solve #179.5 and did some minor changes to the CSS as well.

I'm wondering if we should move some of the markup generation from JavaScript to PHP. Any thoughts on that?

seanb’s picture

@lauriii Manually tested it and everything still works as expected, thanks!

I'm wondering if we should move some of the markup generation from JavaScript to PHP. Any thoughts on that?

The reason this is now done in JS is #147. The dropzone markup should not be added when JS is disabled.

lauriii’s picture

The reason this is now done in JS is #147. The dropzone markup should not be added when JS is disabled.

Okay, seems like a good reason to do it in JavaScript instead of PHP.

brankoc’s picture

StatusFileSize
new44.11 KB

With regard to patch #193:

1) If Javascript is disabled, the remove button disappears for single fields (cardinality = 1). Same goes for the default image field on the field settings screen.

Adding "position: relative" to the right parent element should solve this.

2) The design for an uploaded file shows a bar of about 45 pixels high. The minimal height by patch 193 is 100 pixels. Is there a reason for this? In #167 it was still the correct height, adding a 'min-height' in #169 seems to have broken this. #169 was presumably a fix for #167.1, although the patch in #167 already fixed this, so I am not sure why the other method was chosen.

3) On narrow screens, the default image gets wedged next to the description, which makes it so there is very little space for either. It would be better if they were stacked vertically on narrow screens.

[screenshot]

Removing ".dropzone {display: flex; }" for narrow screens (in a mobile first design this would imply adding 'display: flex' to wide screens) would solve this.

4) If Javascript is disabled, the "Add a file" label (cardinality > 1) is not displayed, even though the File field is no longer a dropzone. Why is this?

KondratievaS’s picture

StatusFileSize
new72.47 KB

I tested in several browsers and got following result:
1. Chrome
- (Windows): everything works as expected
- (Linux): it is impossible to drag several images/files in field(multiple), works only if user wants to drag 1 image/file
2. FF
- (Windows): it is impossible to drag image/file in field
- (Linux): same behavior as in Chrome
3. IE: same behavior as in FF (Windows)

Also, should we have icon when for Image field when field is filled, like we have for File field? (screenshot in attachment)

test

seanb’s picture

StatusFileSize
new33.65 KB
new4.98 KB

#196:
1. Fixed.
2. Fixed.
3. Fixed. The responsive layout is still a challenge though, specially the table.
4. This is actually on purpose. Not all improvements are dropzone related, and I think this is 1 of them. That is also the reason the CSS is split up in dropzone.css and managed-file.css. The managed-file.css should also improve the non-JS layout.

#197:
I have tested windows and mac, ie11 (windows) / chrome (both) / firefox (both) / safari (mac only), and I can't seem to reproduce the issues. The only place where drag/drop uploading doesn't work is IE11, but that is because IE11 doesn't support HTML5 drag and drop uploads. I did find some cross browser styling issues (specially IE11) with the multiple files table and flexbox that should now be fixed.

Could you maybe create a video of what is happening? Or some steps to reproduce?

KondratievaS’s picture

StatusFileSize
new1.86 MB

Video in attachment

brankoc’s picture

Dragging files from the file upload dialogue onto the dropzone is certainly a novel approach. Is this a browser problem or a problem of this patch? When I tried to do the same at wetransfer.com for instance, it failed in both Firefox and Chrome. Interestingly, I succeeded in dragging a file from the Chrome dialogue to the Firefox dropzone (still talking about Wetransfer), but failed the other way around.

I haven't tried this with the current patch yet.

Edit: oh, I wanted to ask, what is the use case for this scenario? Also, what is supposed to happen if you drag a file successfully from the dialogue to the dropzone and then click the open/add/submit button of the dialogue with the file still selected?

seanb’s picture

Thanks for the video, that was really helpful! It worked in chrome, firefox and safari on my mac, but this seems to be different for other operating systems. Could you try if it works on https://www.dropzonejs.com/ for example?

Drag and drop is a bit tricky, not very well documented and I see lots of implementation differences between browsers, operating systems and applications.

brankoc’s picture

Here are my findings with https://www.dropzonejs.com on Windows 10 Home.

Firefox 64: dragging from the file dialogue onto the dropzone works.
Chrome 72: dragging from the file dialogue onto the dropzone works.
Edge 42: dragging from the file dialogue onto the dropzone works.

Also, I am able to drag and drop from the file dialogue of one browser onto the dropzone of another browser.

The one problem I run across with dropzonejs.com is that Firefox does not always work the first time around and I need to drag a file a second time for the dropzone to work.

Dropzonejs.com supports dragging an image from a diffferent location on the same page to the dropzone for Firefox and Edge but not for Chrome in this configuration. For this test I used the Dropzonejs.com logo.

brankoc’s picture

For completeness sake, using the same set-up as in my dropzonejs.com tests and the latest patch of this issue:

Firefox 64: dragging from the file dialogue onto the dropzone fails.
Chrome 72: dragging from the file dialogue onto the dropzone works.
Edge 42: dragging from the file dialogue onto the dropzone fails.

Firefox 64: dragging from the browser canvas onto the dropzone fails.
Chrome 72: dragging from the browser canvas onto the dropzone fails
Edge 42: dragging from the browser canvas onto the dropzone fails.

seanb’s picture

Thanks @brankoc, the issues seem fixable, but this is not at all standard behaviour. Looking at all complexity of dropzone.js, I'm not sure if we want to add and maintain solutions for all these cases. If we want to support that, it might be a good idea to open a followup to investigate if we should adopt a 3rd party library like dropzone.js.

seanb’s picture

After thinking about it a bit more, there are probably a lot of (edge?) cases that do not work. We should probably determine what we want to support before we start looking at the code or libraries to support this.

What does this patch fix:

  • Drag and drop from desktop
  • Drag and drop from Finder / Windows File Explorer type window (external from the browser)

What we currently do not support:

  1. Drag and drop from file explorer opened by a file field (see video in #199)
  2. Drag and drop images in the current tab (for example, dragging the logo to the file field)
  3. Drag and drop images from another browser tab
  4. Drag and drop from 3rd party applications like Word, Photoshop, Paint etc
  5. Drag and drop from Remote desktop
  6. ....More thing we should mentions here?

So the big questions:

  1. Are (some of) the unsupported cases standard user behavior?
  2. Which should we support and is it ok to fix this in a followup?

I will ask for feedback on this in the UX channel / meeting.

webchick’s picture

With the caveat that I haven't seen this patch in action yet, I think as long as it's not preventing users from doing those things in a non-draggy-droppy way (e.g. it starts spewing out fatal errors or what have you where previously there were none), we can probably get a foundation in and work upward in follow-ups from there. What we want to avoid is any given patch adding to the critical bug count of things that must be resolved before release.

Most of those seem "nice to have" at best or even "why would you even do that?" to me, though. (e.g. dragging an image from another browser tab, dragging the site logo into the upload box.)

webchick’s picture

Also, holy crap, @brankoc... thank you so much for all your great manual testing work here!!

brankoc’s picture

StatusFileSize
new33.71 KB
new871 bytes

1) #198.1 says that #198 fixes #196.1, but I see the fix neither in my browser, nor in the interdiff. Fixed in #208.

2) The fix for #196.3 lacks white-space around the preview. Added in #208.

3) I have not been able to reproduce #197.4 (missing icon for uploaded image). In contrast to the screenshot of KondratievaS, I get a thumbnail of the uploaded image.

seanb’s picture

Issue tags: +Needs frontend framework manager review
StatusFileSize
new1.02 KB
new33.73 KB

Thanks @brankoc. Fixed some minor nits. Besides that looking good to me! Not sure what else is needed to get this done. I think the only thing we now need is sign off from a frontend framework manager.

andrewmacpherson’s picture

Issue tags: +accessibility, +Needs accessibility review

Whenever you create new UI widgets with javascript, please remember to add the accessibility tag. If accessibility isn't considered, it most likely won't be accessible.

#182 mentions needing an accessibility review, but it wasn't tagged. That comment also suggests leaving accessibility as a follow-up. If you're not tagging this for the accessibility maintainers to see, leaving it to a follow-up amounts to ignoring the accessibility gate, and entails a big risk that an innaccessible feature will be introduced in a minor rease, and not fixed for several more releases.

/rant done.

There's a lot going on in this one. The progress bars - are they the same ones that batch API uses? Those are flaky (gibberish, sometimes) in screen readers. So far we've only used them in a handful of operations, but using them on content editing forms means a much bigger audience for them.

For multi-value file fields, is there a situation where several prigress bars will be moving at once? Say when uploading large files.

We also need to consider informing users of the outcome, and where focus goes after the upload.

I'll give this a try with assistive tech soon.

There's a mention of truncating file names. Is that still happening? That can make it hard for everybody to understand. For example, when truncating means a version number, datestamp, or other differentiator, isn't communicated.

brankoc’s picture

Issue tags: -accessibility +Accessibility

Filename shortening was removed in #169.

seanb’s picture

#182 mentions needing an accessibility review, but it wasn't tagged. That comment also suggests leaving accessibility as a follow-up.

To be fair, I did not try to suggest a11y issues in the patch should be solved in followups. At the time I suggested to postpone a specific new change that could impact a11y. After discussing with the UX team we already decided that the suggested change was a bad idea, so that was why I didn't follow up with you on that specific point.

There's a lot going on in this one. The progress bars - are they the same ones that batch API uses? Those are flaky (gibberish, sometimes) in screen readers. So far we've only used them in a handful of operations, but using them on content editing forms means a much bigger audience for them.

For multi-value file fields, is there a situation where several prigress bars will be moving at once? Say when uploading large files.

We are currently not showing any progress bars. We show the standard AJAX throbber for the upload and remove steps. There is a followup for the progress bars #2863846: File Field design update progress bar.

We also need to consider informing users of the outcome, and where focus goes after the upload.

Not really sure what outcomes you are referring to? If you have suggestions on how to improve that is more than welcome.

There's a mention of truncating file names. Is that still happening? That can make it hard for everybody to understand. For example, when truncating means a version number, datestamp, or other differentiator, isn't communicated.

As brankoc mentioned, this has been removed because of possible UX / a11y issues, and was also not part of the original IS.

lauriii’s picture

Issue summary: View changes
Status: Needs review » Needs work
StatusFileSize
new62.78 KB
  1. We are still missing the remaining files indicator and I don't see a follow-up for that. Could you open that?

  2. Throbber is rendered on top of remove text when removing a file.
  3. +++ b/core/themes/seven/css/components/managed-file.css
    @@ -0,0 +1,160 @@
    +  margin: 10px 0;
    

    I think this would look better with margin: 10px 0 25px;. Maybe we could confirm that with someone from the UX team?

  4. +++ b/core/misc/icons/bebebe/dropzone-new.svg
    diff --git a/core/misc/icons/ee0000/ex.svg b/core/misc/icons/ee0000/ex.svg
    new file mode 100644
    
    +++ b/core/themes/seven/css/components/managed-file.css
    @@ -0,0 +1,160 @@
    +  max-width: 80px;
    

    We don't need max-width given that we already have a static width.

  5. +++ b/core/themes/seven/js/dropzone.es6.js
    @@ -0,0 +1,135 @@
    +          let buttonText = 'Add file';
    ...
    +            buttonText = 'Add files';
    

    This should be translatable.

  6. +++ b/core/themes/seven/js/dropzone.es6.js
    @@ -0,0 +1,135 @@
    +            if (cell.find('.file-size').length) {
    +              cell.find('.file-size').append(marker);
    

    We probably shouldn't add a js- prefixed class here since the markup is hardcoded in a preprocess function. Let's just add a todo referring to #3033279: Move markup from template_preprocess_image_widget to a template.

  7. +++ b/core/themes/seven/css/components/managed-file.css
    @@ -0,0 +1,160 @@
    +.form-type-managed-file table tr td {
    ...
    +.form-type-managed-file table tr.draggable td:first-child {
    ...
    +.form-type-managed-file table tr.draggable td:first-child a.tabledrag-handle,
    +.form-type-managed-file table tr.draggable td:first-child .form-managed-file {
    ...
    +.form-type-managed-file table tr.draggable td:first-child a.tabledrag-handle {
    ...
    +.form-type-managed-file table tr th:last-child,
    +.form-type-managed-file table tr td:last-child {
    ...
    +.form-type-managed-file table tr th:last-child {
    ...
    +.form-type-managed-file table tr td:last-child {
    

    Could we remove table and tr from these selectors?

  8. +++ b/core/themes/seven/css/components/managed-file.css
    @@ -0,0 +1,160 @@
    +.form-type-managed-file .image-widget {
    ...
    +.form-type-managed-file .image-preview,
    +.form-type-managed-file .image-widget-data {
    ...
    +.form-type-managed-file .image-preview {
    ...
    +[dir="rtl"] .form-type-managed-file .image-preview {
    ...
    +.form-type-managed-file .image-preview img {
    ...
    +.form-type-managed-file .image-widget-data {
    

    We should be able to drop .form-type-managed-file from these selectors.

  9. +++ b/core/themes/seven/css/components/managed-file.css
    @@ -0,0 +1,160 @@
    +.form-type-managed-file .description ul {
    

    We already have a template override for this, so we could add a class to the ul element and target that.

  10. +++ b/core/themes/seven/js/dropzone.es6.js
    @@ -0,0 +1,135 @@
    +        .addClass('dropzone-enabled')
    

    How about changing this to .form-managed-file-wrapper--dropzone? This would allow us to clean up the CSS.

  11. Have you considered writing test coverage for this?
seanb’s picture

StatusFileSize
new39.75 KB
new50.96 KB
new51.61 KB
new21.98 KB
new43.02 KB

#213
1. I added it to #3029340: File Field design update: Multiple file fields
2. Fixed. Moved it on top of the close button.
3. Fixed, I agree.
4. Fixed.
5. Fixed.
6. Fixed.
7. Fixed.
8. Fixed.
9. Fixed.
10. Fixed.
11. The only thing we can test is the markup changes. So added that. We didn't really have any tests for that at all, so that's why I was a little unsure. While running the tests I noticed that when the managed_file element allows multiple files in a custom form, the display is totally different. So that was very useful, see screenshots. Since we don't want to mess this up for other themes I added some JS to move elements around. The structure of the managed_file element is really crap, and if you change it to much in seven_process_managed_file for example, the functionality breaks. So I think this is the best I could do.

Before the latest changes:
Managed file before #214.

After the latest changes:
Managed file after #214.

After the latest changes (RTL):
Managed file after #214.

seanb’s picture

Status: Needs work » Needs review
StatusFileSize
new407 bytes
new43.04 KB

Needs review off course. An noticed 1 small thing in the screenshot.

andrewmacpherson’s picture

What's the current propisal? #212 says we aren't using progress bars but the issue summary says we are.

andrewmacpherson’s picture

#212:

Not really sure what outcomes you are referring to?

I mean the outcomes of the file upload operation, such as: it succeeded, the file was larger than the allowed size, or other failures.

seanb’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update

The IS already stated the progress bar was postponed to a follow up, but I changed it a bit to hopefully make that more clear.

finnsky’s picture

StatusFileSize
new160.7 KB

I catched error after multiple add/remove file actions

brankoc’s picture

I mean the outcomes of the file upload operation, such as: it succeeded, the file was larger than the allowed size, or other failures.

After success, the state of the upload field changes. On a single value field, the file input is replaced by a link or a preview (in case of an image) of the file and optional or required extra fields (description, alt attribute et cetera). On a multiple value field, the file input will be prefixed by links or previews.

Upon (partial) failure, the file input field will remain the same, but will be prefixed by either notices or errors.

A typical notice is one that says you tried to upload more files than allowed, and files X and Y were not uploaded, while Z was.

A typical error is one that says that you are not allowed to upload a file of type X.

These look like typical Drupal messages to me, so I have reviewed the patch under the assumption that the messages were not part of the patch. I will however post a couple of example screenshots later today.

brankoc’s picture

Status: Needs review » Needs work
StatusFileSize
new7.77 KB

This is not a complete review of 215, but something I noticed: the error message for an image field is pushed all the way to the side, rendering it unreadable.

What I expected: an error message rendered on top of the image field.

What I got: an error message to the side of the image field.

This is in Win 10 / Firefox 65.

The same happens in multiple image fields.

See illustration (cropped).

The message box is rendered inside a div with class "image-widget" which is set to 100 pixels wide inside dropzone.css.

brankoc’s picture

In addition to #220, here are some screenshots illustrating the outcomes.

a. Single image field, before and after the upload.

[screenshot]

Shown here two states, before and after the upload. Before the upload, the user sees a dropzone, an "Add file" button, a description and a default image. After the upload, the user sees an image preview, file name, file size, a field for an alternative text (required), a partial description and a remove button.

b. Multiple files field, before and after the upload.

[screenshot]

Shown here are two states, before and after the file upload. Before the upload, the user gets a dropzone, an "Add files" button and a description. After the upload, the user gets a list of file names with drag handles, remove buttons, followed by a "before-the-upload" dropzone.

c. Limited multiple files, notice after the upload attempt.

[screenshot]

If the user tries to upload more files than is allowed by the multiple files upload field, the system only uploads a selection of files and displays a notice. For example: "Field field_five_files can only hold 5 values but there were 6 uploaded. The following files have been omitted as a result: 1234567890abc.txt."

d. Unlimited files, error message after the upload attempt.

[screenshot]

If a user tries to upload a file of the wrong file type, the state of the field does not change, but an error message is displayed inside or over the control. For example: "The selected file test-default.png cannot be uploaded. Only files with the following extensions are allowed: txt."

Re: a+b, note that more sub-fields are possible after the upload, for example a Title field for images and a Description field for files.

I don't know how this works with assistive technologies.

seanb’s picture

Status: Needs work » Needs review
StatusFileSize
new1.44 KB
new43.74 KB

#219 This is actually an existing bug/issue with managed file fields, and this also happens without this patch. Could you file a different issue for that?

#221 / #222 Fixed. There was some client side validation for file extensions which places the error messages in a different location than the server side messages.

seanb’s picture

StatusFileSize
new3.53 KB
new43.85 KB

Attached patch fixes a JS issue. We are trying to overwrite Drupal.file.validateExtension to move the error messages, but since this was added to every page the JS breaks on pages without managed form fields. Added a special dropzone library and attached to the managed file field.

Also moved the file field to the dropzone 'trigger' section to make the dom order match the visual tabbing order.

Status: Needs review » Needs work

The last submitted patch, 224: 2113931-224.patch, failed testing. View results

lauriii’s picture

It seems like the latest patch is broken. I was unable to upload files or images at all after applying the patch.

seanb’s picture

Status: Needs work » Needs review
StatusFileSize
new3.52 KB
new43.82 KB

So sorry about that, not sure how I missed that. Must have been late. Attached patch should fix the issue.
On a side note, it's good to see the tests work!

wim leers’s picture

StatusFileSize
new65.96 KB
  1. 🥳🥳🥳 This looks and functions amazingly. It's a massive UX improvement. I first commented on this >4 years ago, in #20.
  2. +++ b/core/misc/icons/bebebe/dropzone-new.svg
    @@ -0,0 +1,13 @@
    +<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="100" width="500" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
    

    🐛This SVG hasn't been optimized yet.

  3. +++ b/core/modules/file/tests/src/FunctionalJavascript/FileManagedFileElementTest.php
    @@ -41,50 +41,82 @@ public function testManagedFile() {
    -    foreach ([0, 1] as $tree) {
    ...
    +    foreach (['stable', 'seven'] as $themename) {
    +      \Drupal::service('theme_installer')->install([$themename]);
    +      $theme_config = \Drupal::configFactory()->getEditable('system.theme');
    +      $theme_config->set('default', $themename)->save();
    +      foreach ([0, 1] as $tree) {
    

    👍 This is just changing the the pre-existing test coverage to be tested in multiple themes.

  4. +++ b/core/themes/seven/css/components/dropzone.css
    @@ -0,0 +1,222 @@
    +  margin-left: -0.2em;
    

    🐛 This needs to be marked LTR and needs accompanying RTL. The last screenshot in #214 also shows this is currently visually broken in RTL.

  5. +++ b/core/themes/seven/css/components/dropzone.css
    @@ -0,0 +1,222 @@
    +  content: "+";
    

    🤔 Shouldn't this have padding-right just like .button-action:before in action-links.css? Without that, the button looks like: +Add file instead of like: + Add file.

  6. +++ b/core/themes/seven/seven.theme
    @@ -145,6 +176,15 @@ function seven_preprocess_maintenance_page(&$variables) {
    +function seven_preprocess_file_widget_multiple(&$variables) {
    ...
    +    $variables['element'][$key]['#title_display'] = 'invisible';
    

    👍 We want to do this only in Seven, because other themes should still have the title visible since they don't use the dropzone. The dropzone is Seven-specific. (At least for now.)

  7. +++ b/core/themes/seven/seven.theme
    @@ -164,6 +204,13 @@ function seven_form_node_form_alter(&$form, FormStateInterface $form_state) {
    +function seven_theme_suggestions_form_element_alter(&$suggestions, $variables) {
    +  $suggestions[] = 'form_element__' . $variables['element']['#type'];
    +}
    
    --- /dev/null
    +++ b/core/themes/seven/templates/form-element--managed-file.html.twig
    

    🤔 AFAICT this is not used anywhere? D'oh it is. But … why can't this use file-managed-file.html-twig?

  8. +++ b/core/themes/seven/templates/file-upload-help.html.twig
    @@ -0,0 +1,16 @@
    +    <li>{{ description|trim('.') }}</li>
    

    👍🤔 Why are we trimming periods? Because instead of the default template's HTML of <br>-separated descriptions, we're converting it to a <ul> here automatically. Cool :)

  9. +++ b/core/themes/seven/templates/file-widget-multiple.html.twig
    @@ -0,0 +1,16 @@
    +<div class="form-type-managed-file">
    +  {{ table }}
    +  {{ element }}
    +</div>
    

    👍 Unlike the default template, this is wrapping it in a <div> with a particular class to allow these to be targeted together by CSS.

  10. 🤔 In manual testing, I think the default image handling is perhaps not working as intended. It looks different for me than in the screenshots above. I'm testing with core's default article node type. I just uploaded a default image at /admin/structure/types/manage/article/fields/node.article.field_image. Then the default state looks like this:
seanb’s picture

StatusFileSize
new9.97 KB
new43.68 KB

#228
1. Nice. Hope it doesn't take another 4 years to get it done though :)
2. Fixed.
3. :)
4. Fixed. Nice catch! Also consistently marked things LTR since I didn't know we did that. I like it.
5. Fixed.
6. Exactly, we try to keep the changes to seven only (as much as possible).
7. The form element also contains the field description, field error element, and other stuff. The file-managed-file.html.twig template is just a part of the whole thing, and we need to change everything to make it look like the design.
8. :)
9. Fixed.
10. Not sure what you mean? Since the default image is not designed, and the left side (where it originally was) is now used by the dropzone, I moved the preview image to the right side of the element. Your screen is wider than my screen apparently, but other than that it seems to look fine?

lauriii’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: -Needs frontend framework manager review
StatusFileSize
new15.07 KB

Thank you @seanB for pushing this forward! 🙏

  1. +++ b/core/themes/seven/css/components/dropzone.css
    @@ -0,0 +1,227 @@
    +.dropzone__trigger.is-hovering {
    

    This element is missing focus and active styles.

  2. +++ b/core/themes/seven/css/components/managed-file.css
    @@ -0,0 +1,166 @@
    +.form-type-managed-file .remove-button:focus {
    +  outline: none;
    +  box-shadow: none;
    +}
    

    If we remove the default focus styles, we should replace them with our own styles.

  3. +++ b/core/themes/seven/js/dropzone.es6.js
    @@ -0,0 +1,167 @@
    +      .closest('div.js-form-managed-file')
    

    Is there a reason we have to specify the element type here?

  4. +++ b/core/themes/seven/css/components/managed-file.css
    @@ -0,0 +1,166 @@
    +.form-type-managed-file .draggable td:first-child a.tabledrag-handle,
    ...
    +.form-type-managed-file .draggable td:first-child a.tabledrag-handle {
    

    Is there a reason we have to specify the element type here?

  5. +++ b/core/themes/seven/css/components/managed-file.css
    @@ -0,0 +1,166 @@
    +.form-type-managed-file input.form-text {
    

    Is there a reason we have to specify the element type here?


  6. It seems like the line breaks aren't working as specified in the specs.
seanb’s picture

Status: Needs work » Needs review
StatusFileSize
new4.93 KB
new44.4 KB

Fixed #230.
1. Added focused class to file input. Active doesn't apply here I think that is for links only right?
2. Fixed. Not sure why I removed that. Added some extra padding to make it look better on focus.
3. Fixed. Don't think so.
4. Fixed.
5. Fixed.
6. Fixed. Changed to display inline.

lauriii’s picture

I have no further feedback at this point. Thank you @seanB! We should still try to get a review from someone in the accessibility team.

wim leers’s picture

#229.10: I mean that alt/title are missing. I expect (perhaps wrongly) those to be shown in the same place as when I've uploaded an image myself, and for those input[type=text] to be disabled. But if it's not in the design, I think it's fine as-is; it's still a massive improvement :)

Like @lauriii, I too think this is ready, and a massive step forward. Any remaining small imperfections should be addressed in follow-ups, we shouldn't wait until every detail is absolutely perfect, precisely because it's such a big improvement.

bojanz’s picture

Nitpicks!

+    foreach (['stable', 'seven'] as $themename) {
+      \Drupal::service('theme_installer')->install([$themename]);

$themename looks very odd. Can we do $theme_name? That's how it's called elsewhere.

+            $uploaded_file = $this->assertSession()
+              ->waitForElement('css', '.file--mime-text-plain');

+            $this->assertSession()
+              ->responseContains(t('The file ids are %fids.', ['%fids' => '']));

We don't usually break up calls into multiple lines like this, guessing someone's editor did it automatically?

+            $this->getSession()
+              ->getPage()
+              ->attachFileToField($file_field_name, $this->container->get('file_system')
+                ->realpath($filename));

That line is too long and does too much.
$this->container->get('file_system')->realpath($filename) can be done on the previous line.
We can assign $this->getSession()->getPage() to $page if the line length worries us. Or do it with $this->getSession().

seanb’s picture

StatusFileSize
new6.25 KB
new44.24 KB

Fixed #234

dww’s picture

This (mostly) looks absolutely amazing! Definitely a huge improvement for core. BRAVO!!

I really wanted to RTBC this, but instead it's NW for (at least) 3 things. :/

Plain 8.7.x-dev site with the patch applied, caches rebuilt, etc.

A) First thing I tried was using the new widget on an image field that only allows a single file (e.g. user_picture). The image I used happened to be the most recent screenshot I took for another issue, with a big long filename. The name and size crash into the 'X' remove link. The "remove" text itself (white by default) is over-writing the end of the filename, which looks weird enough:

single image widget with a long filename gets overwritten by mostly hidden remove text and X

But the bug is really obvious when you hover and everything turns red:

single image widget with a long filename gets very overwritten by red remove text and X on hover

I then setup a 5 more fields on this node type: cardinality 1, 3 and unlimited for both image and file (for a total of 6 fields). I tested all of them, and the single-value image field is the only one that has this problem. Every other permutation is doing something special to wrap the filename so it doesn't crash into the remove link. So it seems this is already a mostly solved problem, but there's an edge case for the 1-image configuration that also needs fixing.

B) When I went to configure the widgets on "Manage form display", I noticed a minor UI WTF. The summary says "Progress indicator: throbber" but when I click on the gear icon to see what the other choices are and try them out, there's no setting at all. :/ I guess that's supposed to be at #2863846: File Field design update progress bar or something, but until that lands, it seems a little cruel and a lot confusing to advertise the "throbber" as a widget option if I can't change it. ;) Can we just rip that out from the settings summary and add it back in once there's a setting we can change that needs to be summarized?

Summary:
file widget summary mentions 'throbber'

Empty widget settings:
file widget settings has nothing I can change

C) Once I filled up the 3-files field, the uploader disappeared (as intended!). However, so, too, did the tiny "Maximum 3 files" that was hidden amongst the file upload instructions. If I didn't happen to notice (and remember) that this field was limited, I'd be rather confused/annoyed that the uploader just disappeared while I was trying to finish uploading all those interdiffs. ;)

In progress, easy to miss the maximum:

File field with limit of 3, in progress, 1 slot remaining

Now with 3, uploader gone (yay) along with the explanation why (boo):

File field with limit of 3, all full, uploader gone, no indication why

Can we preserve "Maximum 3 files" in this case?

- - -

Time permitting (!) I'll do a deep-dive review of the patch (which is what I was hoping to do instead of this kind of click-test-screenshot review), but I'm really slammed so I can't make promises.

Thanks/sorry!

dww’s picture

Did a reasonably careful review of the code, too. Mostly nits. A few informational/educational questions.

  1. +++ b/core/modules/file/tests/src/FunctionalJavascript/FileManagedFileElementTest.php
    @@ -37,54 +37,79 @@ protected function setUp() {
         $filename = \Drupal::service('file_system')->tempnam('temporary://', "testManagedFile") . '.txt';
    +    $file_path = $this->container->get('file_system')->realpath($filename);
    

    The line immediately above uses a different way to get the file_system service. :/ I know #2066993: Use magic methods to sync container property to \Drupal::getContainer in functional tests still an open debate, but can we please standardize on one approach and use it consistently for this method? ;) I vote \Drupal::service() for this.

  2. +++ b/core/modules/file/tests/src/FunctionalJavascript/FileManagedFileElementTest.php
    @@ -37,54 +37,79 @@ protected function setUp() {
    +            $path = 'file/test/' . $tree . '/' . $extended . '/' . $multiple;
    

    Any reason not to do: $path = "file/test/$tree/$extended/$multiple"?

  3. +++ b/core/themes/seven/css/components/dropzone.css
    @@ -0,0 +1,228 @@
    +.dropzone__no-trigger .description li:after {
    +  padding: 0 5px;
    +  content: "\00b7";
    +}
    

    #include "dww/ignorance.h"

    Does :after do what you expect in the RTL vs. LTR worlds?

  4. +++ b/core/themes/seven/seven.libraries.yml
    @@ -42,6 +43,18 @@ global-styling:
    +dropzone:
    +  version: VERSION
    +  css:
    +    theme:
    +      css/components/dropzone.css: {}
    +  js:
    +    js/dropzone.js: {}
    +  dependencies:
    +    - core/drupal.ajax
    +    - core/drupal.progress
    +    - file/drupal.file
    +
    

    What about sites that don't use seven for their admin theme? Or sites that let users upload files (e.g. user_picture) without using an admin theme at all? I guess they get no dropzone? Nor most of the other goodness from all this effort. I just unchecked the "Use the administration theme when editing or creating content" setting on my local test site, and lo, /node/add/article looks somewhat sad. It all still works, such as it is.

    Apologies I didn't read every comment in this issue. Looks like @jhedstrom asked the same thing in #45 but I don't see any real response. Why is all of this goodness so intimately tied to seven instead of being available to all file upload fields in some capacity?

  5. +++ b/core/themes/seven/templates/form-element--managed-file.html.twig
    @@ -0,0 +1,98 @@
    +    <div{{ description.attributes }}>
    ...
    +      <div{{ description.attributes.addClass(description_classes) }}>
    

    Why does the second one of these add description_classes but not the first?

  6. +++ b/core/themes/seven/templates/image-widget.html.twig
    @@ -8,5 +8,14 @@
    -{{ attach_library('classy/image-widget') }}
    

    I'm clearly missing something, please forgive me, but what's up with this? Looking at core/themes/classy/css/components/image-widget.css it's got an @todo about wanting to include this library starting in D9. Now we're removing it from here? ;) Also, I don't see what we're attaching instead. Is that the dropzone from seven_process_managed_file()?

seanb’s picture

Status: Needs work » Needs review
StatusFileSize
new5.91 KB
new46.93 KB

#236

A. Fixed. This was apparently not that easy to solve. I needed to add some extra wrapper elements to make the filename, file size and remove button float nicely.
B. I could not reproduce this. The patch also didn't touch the settings code at all? This is in FileWidget::settingsForm(). Besides that, the changes we are making are for the Seven theme only, so progress bars in other themes will work as before. We should try to keep all changes contained to Seven as much as possible.
C. This is a separate (already existing) issue. If I checkout a clean 8.7.x branch with an image field with limited cardinality, the upload field and the description also disappear.

#237

1. Fixed. Nice catch. I just copied that line to the top so the inconsistency was already in the test.
2. Fixed. Again, just added a foreach so this was already in the test. But I can change it if you like.
3. It does :). This adds the dots between the validators in the description below the field.
4. The design was to improve the seven theme. We can't change this in other themes because we have no idea what they look like. This issue was created to implement https://groups.drupal.org/node/283223#File_Field, which is a style guide proposal for Seven.
5. Not sure? @see core/themes/stable/templates/form/form-element.html.twig. I don't think we should change that in this patch.
6. We are using a Seven specific override of the image-widget.html.twig template, and don't need the classy styles anymore. We have added a generic css/components/managed-file.css to seven.libraries.yml for all managed file fields, and add more dropzone specific CSS/JS in seven_process_managed_file().

dww’s picture

Great, thanks! Getting closer. ;)

Re: #238.A:

Side note: Seven is current broken-as-hell with a long filename in a multi-value file field. Before the patch:

Multi-value file field with a long filename, seen in Seven without patch

After the patch:

Multi-value file field with a long filename, seen in Seven after the patch

So, that's a huge improvement. ;) However, why is the file size wrapping there onto yet another line? Also visible with a single-value image field:

Single-value image field with long filename, size wraps onto a newline for no reason

Needs work? Not sure it's worth it.

Related point (probably out of scope) it's not obvious why things wrap to get out of the way of this hidden "Remove" text until you hover. That's slightly weird, but it's probably too late to do anything about it or change anything now.

Re: #238.B: Whoops, I didn't have uploadprogress enabled locally. ;) #236.B is now at #3037204: If upload progress extension is not available, disable the file field widget settings and has nothing to do with this patch. ;)

Re: #238.C: fair enough. #NeedsFollowup. ;) *shrug*

#238 numbered points:
1. Cool. The whole \Drupal:: war can happen elsewhere, but at least we're locally consistent. Thanks.
2. Thanks.
3. Cool! Duly noted. Thanks for the info. :)
4. :( So we've "moved dropzone into core", but only for Seven? Ugh. I *really* don't like this decision. Not sure what to do about it, or how to change course at this point. Bummer.
5. Seems like a bug, and if we're adding a new template to seven for all this, we should IMHO fix it. Maybe it should be a separate follow-up? I still don't grok (and am running out of patience with) our policy around when we can and can't fix bugs in our theme templates. :( But it seems wrong to commit known-broken templates like this. *shrug*
6. Thanks. I missed the css/components/managed-file.css in the global seven library. Makes more sense now.

New point:

D) Is it viable accessibility-wise to have this red-only-on hover business? Doesn't that violate the principle of not relying on color to convey meaning? I guess we have the word "Remove" and an X icon, so we're not *relying* only on color. But it does seem a bit weird how it works. Kinda related to my side-point on A above about the hidden "Remove" text causing things to wrap when at first look they don't need to. Again, probably too late to change any of that now.

Anyway, potentially still NW for #236.A (to at least not wrap the filesize separately) and #237 4 and 5 (policy decisions?), but I'll leave NR for now.

Otherwise, I'm +1 to RTBC pending accessibility sign-off.

Thanks again!
-Derek

seanb’s picture

#236.A The filename and file size text are 2 span elements with word-wrap inside a flex item element. I tried having the filename and file size display inline, but then the flow out of their container a bit. Which then causes the remove text to still overlay over the filesize sometimes. So display inline-block seemed to be the best I could do here. I think this is not a blocking issue and we could have a followup to improve this?

#237.4 I don't think this was ever about "moving dropzone into core", but more about improving Seven. Technically we are just styling the managed file field to look like a dropzone. The drop area is actually the input field. Moving dropzone into core would be something I support though.

#237.5 Also not really sure about this. We can't change classy and stable (I know you are working to get around that), but I don't know if the description_classes were omitted from the template on purpose or not. Since we can definitely change Seven, I would propose we make this a follow up as well.

#239.D I'm also curious about the a11y implications of showing the text on hover/focus only. It was never in the design to begin with, I know it at least had UX signoff. Not sure if that has been checked by the accessibility team. It's a very easy change to always show the text though, so we can always fall back on that. Hoping to hear from the a11y team soon!

dww’s picture

Issue tags: +Needs followup

Re: #240 thanks!

#236.A: Hrm, okay. I guess it's an edge-case, and it works (even if a bit ugly), and it's vastly better than what we have now. Definitely non-blocking. Follow-up is fine if there's no "easy" fix now.

#237.4:

I don't think this was ever about "moving dropzone into core", but more about improving Seven. Technically we are just styling the managed file field to look like a dropzone. The drop area is actually the input field. Moving dropzone into core would be something I support though.

I don't understand. This patch adds "dropzone.js" and allows file uploads to work via dropzone-like behavior. But only for Seven. I don't know what "move Dropzone into core" means other than what this patch is doing, except changing where some of this JS and CSS lives, and attaching that library to file fields directly from File module, not Seven. More or less. Are you proposing we do that *after* this lands, as a follow-up?

#237.5: Okay, I guess follow-up is okay here, too.

#239.D: Sounds good. Yeah, maybe to help both this and #236.A we should leave it visible (lower contrast than the X?) by default, and go high-contrast/red on hover?

'Needs followup' is non-blocking to RTBC, but is now true. ;)

Thanks again!
-Derek

seanb’s picture

I don't understand. This patch adds "dropzone.js" and allows file uploads to work via dropzone-like behavior. But only for Seven. I don't know what "move Dropzone into core" means other than what this patch is doing, except changing where some of this JS and CSS lives, and attaching that library to file fields directly from File module, not Seven. More or less. Are you proposing we do that *after* this lands, as a follow-up?

We could split up the Seven specific code from the generic code, and make that available as a library for other themes. I do think we should not be adding this to the managed file field by default, since the changed markup will break existing sites. But as a re-usable component for themes to opt-in I guess it's pretty useful.

I think figuring out how to make this re-usable could lead to some bikeshedding about what should or should not be generic. Let's create a follow up to explore that as well, since that is out of scope for this issue.

I will create the follow ups tomorrow.

dww’s picture

Re: #242: Okay, fair enough. I'm slightly worried that we're going to get this in before 8.7.0-alpha1 (as a major usability win, yay!) but then not be able to make these necessary refactorings since it'd be "too disruptive during alpha" (boo). If the core committers/managers agree we can still fix this between alpha1 and beta1 and make it more widely available, I'm much more inclined to RTBC as soon as the accessibility review is complete.

Regardless, having this is Seven is way better than not at all, so I definitely don't want to hold up progress here.

Thanks!
-Derek

seanb’s picture

StatusFileSize
new2.47 KB
new47.78 KB

Just showed a demo of this patch in the UX meeting. We got some really helpful a11y feedback. The issue with patch #238 was:

  1. The file input and the new button are both announced to screen reader
  2. The new 'Add file' button was missing the type="button" to prevent it from being seen as a submit button by some browsers.

To fix this I have:

  1. Added tabindex="-1" and aria-hidden="true" to the file input field to remove it from the tab order an for screen readers.
  2. Changed the 'for' attribute on the label to associate it with the new 'Add file' button. This makes sure screen readers announce the field same way they would announce the field without the patch.
  3. Added the type="button" to the 'Add file' button.

Hope this addresses the feedback. As far as I can tell the current state of the patch doesn’t seem to change anything for screen reader users.

andrewmacpherson’s picture

This had a demo in the UX call earlier today. Since the UX call, I've thought about this some more. The "button which presses a button" is one too many buttons. I'm not just talking about the keyboard tab order, or screen reader announcements. I'm bothered about the fact that it exists at all. It's too many parts, and it will break for some users somehow. (I don't know how yet, but when it does I'll kick myself for not seeing it.)

#244:

  • Changes 1 and 3 are what we did in a few minutes in the UX call. It's a hacky way to get around the mess of two buttons in the tab order. But I don't expect this to be robust.
  • Change 2, messing about with the <label for> is messy. I don't advise that at all. Now you can click a label, which clicks a button, which clicks a file input. Now that's a three part chain, which is too many parts. This will also break the button for speech control users. They must be able to say the name of the text on the button they see. But the button with visible "add files" text now has an accessible name of "image". REJECTED.

I'm thinking this one through. It isn't going to be easy to make this inclusive and robust. I need to study the DOM more.

JulezRulez’s picture

The Add File button is a good way to make this functionality accessible for everyone.
Fact is that the user gets 2 functionalities: drag-and-drop and browse. So making these 2 functions visible via 2 different UI elements makes it understandable for everybody.
My first reaction when I saw the 2 functions to group them with fieldset and legend. But with hiding the drag-and-drop zone for assistive technology, the label stays, and should put somewhere. While the "Add file button" is an input type=file, this input element should be associated with a label. As I saw in the example, the label was named "Image". Some extra instruction should be added to the label i.e. "Upload image" so WCAG success criterion 3.3.2 is covered.

In 2 days I will discuss this with seanB. I will also think my answer through. It is a though problem.

seanb’s picture

StatusFileSize
new1.54 KB
new47.24 KB

Changes 1 and 3 are what we did in a few minutes in the UX call. It's a hacky way to get around the mess of two buttons in the tab order. But I don't expect this to be robust.

We basically trigger an event on an element when a button is clicked. This should be fine for "regular" browsers, but it would be good to know if there are downsides / limitations I'm not seeing at the moment.

Change 2, messing about with the is messy. I don't advise that at all. Now you can click a label, which clicks a button, which clicks a file input. Now that's a three part chain, which is too many parts.

Fair enough. Removed that from the patch.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jerrylow’s picture

StatusFileSize
new90.15 KB

On a fresh `8.6.13` install I did the following:

  1. Create new content type
  2. Added file field with no limit
  3. Added image field with no limit
  4. Added file field limited to `1`
  5. Applied patch #247

When uploading to the multiple value/no limit fields there's no remove button, did I miss something here?

Missing remove button on multiple file field.

jerrylow’s picture

StatusFileSize
new639 bytes
new47.25 KB
new133.93 KB

Adding patch to address the issue I've mentioned in #249.

Patch 250 sample.

jerrylow’s picture

StatusFileSize
new46.49 KB

Re-roll the patch #250 for `8.8.x`.

martijn de wit’s picture

Are there still some accessibility issues / concerns ? There is a discussion about it in previous posts, but it is unclear for me if everything is addressed and fixed.

It really looks great, I think this is a huge UX improvement!

+1 :)

seanb’s picture

Status: Needs review » Closed (outdated)

We had a long chat today about this issue in the UX meeting (you can watch that here https://youtu.be/aipwkFhZDms?t=1128). Having 2 buttons elements is 100% an accessibility blocker and the general consensus seemed to be that it does not seem likely we can fix the current implementation with a small change.

The designs in this issue turn out to be really hard to implement in an accessible way, and since there are designs being made for the new Claro theme at the moment, we decided on the following approach:

  1. Start with creating accessible markup for a drag & drop file field. The markup seems to be our biggest constraint to get this implemented.
  2. When we know what the markup should be, create new designs for Claro.
  3. Backport the designs so we can start implementation in Seven.
  4. Implement it. We need to also figure out the best way to implement this. The current file field widget contains a lot of complicated code. Changing this is not easy, specially in a backwards compatible way without breaking custom themes and contrib modules. Maybe a new widget and/or element would be best?

As much as it hurts to do this, also seeing how many people worked really hard on this issue before and with me, I think we need to close this issue as outdated. This is a hard lesson in how trying to make something accessible afterwards can sometimes turn out to be impossible, and how important it is to think about accessibility from the very start.

Thanks everyone, hope to see you all in the follow-ups. Created #3064084: Create accessible markup for a drag & drop file upload widget (and ensure there is an accessible alternative interaction) and #3064085: [PP-1] Create design for drag & drop upload widget and ensure accessible keyboard/voice alternative for now.

phenaproxima’s picture

Thanks, Sean. My condolences to everyone who worked so hard on this issue. This kind of outcome can feel crushingly disappointing, and it is indeed a hard lesson and a sad reminder that the process of improving core can be very, very tough. But, that said, from the ashes of this issue, I for one am determined to help build something beautiful, functional, and accessible in the follow-ups.

saschaeggi’s picture

Hey everyone,

I was following this ticket for a while now. I also did port a version to Claro already for testing purposes here #3059615: Field design update: Test Claro migration, as I was very excited to see the work which was done here.
As an outcome to comment #254 I did create a follow-up design ticket in the Claro issue queue #3064236: Accessible Drag & Drop File Upload Widget.
Which will wait for input from #3064084: Create accessible markup for a drag & drop file upload widget (and ensure there is an accessible alternative interaction)

@seanB if you like you could help us designing the file upload for claro once the markup is defined :-)

saschaeggi’s picture

saschaeggi’s picture

jerrylow’s picture

Hey @saschaeggi - I watched the meeting video and it sounds like the main concern here is the duplicated button (I'm trying to find the thread in Slack but searching `in:#media 2113931` yields nothing.

Given the dropzone area is

1. not visually a button,
2. not very useful to keyboard and screen reader users, and
3. redundant.

Is there no reason we can't disable it for tab indexing and `aria-hidden` it? This to me makes more sense from an accessibility perspective. This also eliminates the issues discussed around labelling as well.

xjm’s picture

Status: Closed (outdated) » Closed (duplicate)
xjm’s picture

jaypan’s picture

Issue tags: -JavaScript +JavaScript

The same issue was referenced twice in the last post. I think the other issue was meant to be #3064236: Accessible Drag & Drop File Upload Widget.

teddyvermeulin’s picture

Hi everyone,

Thanks for the great improvement.

I have on error when i use the patch :

Notice: Undefined index: #cardinality in seven_process_managed_file() (line 180 of core/themes/seven/seven.theme).
seven_process_managed_file(Array, Object, Array)
call_user_func_array('seven_process_managed_file', Array) (Line: 999)
Drupal\Core\Form\FormBuilder->doBuildForm('paragraphs_type_edit_form', Array, Object) (Line: 1062)
Drupal\Core\Form\FormBuilder->doBuildForm('paragraphs_type_edit_form', Array, Object) (Line: 563)
Drupal\Core\Form\FormBuilder->processForm('paragraphs_type_edit_form', Array, Object) (Line: 320)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 91)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 38)
Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Could you please help to understand what is the problem ?

Thanks.

ytsurk’s picture

This issue was abandoned and the new solution is kind of stuck ...

You need to manage this patch yourself .. and add an if(isset()) {} for the #cardinality key of that array there.