Problem/Motivation
I noticed an UX regression in the File and Image Widget. The table header is always visible. The bug was introduced in #1898070: file.module - Convert theme_ functions to Twig Commit a4a887ac.
This is the related hunk from commit a4a887ac function template_preprocess_file_widget_multiple.
- $output = empty($rows) ? '' : drupal_render($build);
- $output .= drupal_render_children($element);
- return $output;
+ $variables['element'] = $element;
I think should keep the previous behaviour.
HEAD without patch

HEAD with patch

Beta phase evaluation
| Issue category | Bug, this is a regression. |
|---|---|
| Issue priority | Normal because it doesn't break anything, just looks broken. |
| Disruption | No disruption. |
Proposed resolution
Only display the table header when there are files.
Remaining tasks
None at this time.
User interface changes
The previous behaviour will be restored: The table header will only be displayed when there are files.
API changes
n/a
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 2457793-4.patch | 2.25 KB | claudiu.cristea |
| #5 | 2457793-4-test-only.patch | 1.85 KB | claudiu.cristea |
| file-widget-head.png | 91.78 KB | webflo | |
| file-widget-fix.png | 78.42 KB | webflo |
Comments
Comment #1
webflo commentedComment #2
star-szrGood catch @webflo! Code looks good, should we add a small test?
Comment #3
rogerlenoir commentedThanks webflo. The patch still applies and solves the problem.
Comment #4
rogerlenoir commentedComment #5
claudiu.cristeaAdded also the test. There's "test only" patch proving the regression.
Comment #7
star-szrLooks good, has tests, thanks! Filled out the issue summary and added a beta evaluation.
Comment #8
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed c2b35b0 and pushed to 8.0.x. Thanks!