Problem/Motivation

Issue summary is based on original report by @malc0mn
The setting of the Files displayed by default checkbox in the file widget settings is not respected. The visibility is always on, no matter how you set it up.

Steps to reproduce

1. Create a file field for a node.
2. Select widget 'file'
3. In the settings, tick the Enable Display field checkbox
4. Tick the Files displayed by default checkbox
5. Save
6. Create a new node of the type to which you attached the file field
7. Upload a file to the field
8. Note the state of the checkbox in the DISPLAY column: it is unticked even though we asked for it not to be so.

Proposed resolution

While writing test cases here we noticed that issue seems to be in claro theme.

So overall solution is:

  1. Set the display flag in the field widget so other themes can use it
  2. Use that flag in claro theme's "_claro_preprocess_file_and_image_widget" method to set the correct checkbox values

Remaining tasks

Needs review

User interface changes

Before

before

after

after

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

CommentFileSizeAuthor
#63 interdiff-2272637-57-63.txt2.81 KBashley_herodev
#63 2272637-63.patch7 KBashley_herodev
#61 interdiff-2272637-57-61.txt2.86 KBashley_herodev
#61 2272637-61.patch7.14 KBashley_herodev
#57 interdiff-56_57.txt642 bytesgauravvvv
#57 2272637-57.patch6.6 KBgauravvvv
#56 interdiff-47_56.txt3.64 KBgauravvvv
#56 2272637-56.patch6.6 KBgauravvvv
#55 Screenshot 2023-10-03_after.png18.75 KBashley_herodev
#55 Screenshot 2023-10-03_before.png21.02 KBashley_herodev
#55 interdiff-2272637-47-55.txt3.78 KBashley_herodev
#55 2272637-55.patch63 bytesashley_herodev
#47 interdiff-2272637-45-47.txt741 bytesmohit_aghera
#47 2272637-47.patch6.47 KBmohit_aghera
#45 interdiff-2272637-42-45.txt6.09 KBmohit_aghera
#45 2272637-45.patch6.42 KBmohit_aghera
#42 interdiff_2272637_40-42.txt1.52 KBankithashetty
#42 2272637-42.patch5.13 KBankithashetty
#40 interdiff_2272637_39-40.txt4.91 KBankithashetty
#40 interdiff_2272637_37-40.txt5.41 KBankithashetty
#40 2272637-40.patch5.13 KBankithashetty
#39 interdiff_37-39.txt2.43 KBpooja saraah
#39 2272637-39.patch4.92 KBpooja saraah
#37 interdiff-2272637-34-37.txt5.14 KBmohit_aghera
#37 2272637-37.patch4.92 KBmohit_aghera
#35 interdiff-2272637-24-34.txt5.76 KBmohit_aghera
#35 2272637-34.patch2.93 KBmohit_aghera
#34 2272637-34.patch2.93 KBmohit_aghera
#27 After patch.png66.02 KBBushra Shaikh
#26 After Patch.png11.66 KBprasanth_kp
#26 Before Patch.png11.34 KBprasanth_kp
#24 2272637-24.patch2.82 KBmohit_aghera
#24 2272637-24-test-only-stark.patch2.02 KBmohit_aghera
#24 2272637-24-test-only-claro.patch2.02 KBmohit_aghera
#21 patch status.PNG11.45 KBjaykumar95
#20 2272637-after-patch.png27.86 KBarun velusamy
#20 2272637-before-patch.png15.82 KBarun velusamy
#19 2272637-after_patch.png16.37 KBabhijith s
#19 2272637-before_patch.png17.08 KBabhijith s
#16 2272637.patch871 bytescatch
#4 default_file_visibility_setting_not_respected-file_display-2272637-4-7.x.patch598 bytesmalc0mn
#1 default_file_visibility_setting_not_respected-file_display-2272637-1-7.x.patch426 bytesmalc0mn

Comments

malc0mn’s picture

And here is the patch...

Cheers,

mlc.

Status: Needs review » Needs work
malc0mn’s picture

Hmm, crap... I can see the problem from the tests...

But how to fix it properly then? Because it IS a bug IMHO...

mlc.

malc0mn’s picture

Status: Needs work » Needs review
StatusFileSize
new598 bytes

Attempt 2...

mlc.

Status: Needs review » Needs work
malc0mn’s picture

Status: Needs work » Needs review
malc0mn’s picture

Issue summary: View changes
dcam’s picture

Version: 7.28 » 8.x-dev
Status: Needs review » Needs work

This affects 8.x and will have to be fixed there first. See process() in /core/modules/file/src/Plugin/Field/FieldWidget.php.

I'm not at all familiar with how this widget works, but I'm guessing that this hidden field in the else statement is a no-JS fallback to make sure that the display value is populated when the file's database record is created.

malc0mn is correct that the widget doesn't respect the field setting.

The most obvious problem is that this always-true value prevents the AJAX-rebuilt form from using the field setting.

A second problem is that if a user has JS turned off, selects a file in the widget, and submits the entity form without clicking the Upload button, then the file field is set to be displayed contrary to the field settings and without giving the user the option to display or not.

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

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should 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.

kim.pepper’s picture

Status: Needs work » Closed (outdated)

Closing as outdated. Please re-open if this is still relevant.

catch’s picture

Version: 8.6.x-dev » 9.3.x-dev
Issue summary: View changes
Status: Closed (outdated) » Needs review
Issue tags: +Needs tests, +Bug Smash Initiative
StatusFileSize
new871 bytes

This appears to be a real bug, although now instead of always being checked, the 'display' checkbox is always unchecked when you upload a new file regardless of the setting.

The issue is that when you upload a file the checkbox isn't shown at all, so it's empty, but instead of being empty it should be the default value.

Attaching a patch that fixes it.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Arti Anil Pattewar’s picture

#16 Patch has been tested locally in 9.4 Version and the outcome meets as per the requirement.

abhijith s’s picture

StatusFileSize
new17.08 KB
new16.37 KB

Applied patch #16 on 9.4.x and it works fine.

Before patch:
before

After patch;
after

arun velusamy’s picture

StatusFileSize
new15.82 KB
new27.86 KB

I have verified the patch #16 and tested it against the Drupal version 9.4.x-dev. The patch works fine and I have added the before and after screenshots for reference.

jaykumar95’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new11.45 KB

Tested on Drupal 9.4.5
patch applied successfully.

bnjmnm’s picture

Status: Reviewed & tested by the community » Needs work

@Arun Velusamy #20 no reason to provide screenshots when they've been provided in an earlier comment. That is not something that will receive issue credit.

@Jaykumar95 #21 providing a screenshot of a patch applying provides no benefit. We have automated tests such as the ones that run in #16 that will fail if a patch can't be applied. This type of comment also receives no credit.

This should not be set to RTBC. Comment #16 correctly said this needs tests, so automated tests should be added to confirm this is addressed.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mohit_aghera’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new2.02 KB
new2.02 KB
new2.82 KB

@catch
This issue seems to be related to claro theme.
I tried to reproduce the bug on simplytest.me for seven and stark theme.
It seems to be working fine for seven and stark theme.

When I switched the theme to claro theme, it is causing issues.

To reproduce the issue, I am uploading two test-only patches.
On local, test only patch with stark 2272637-24-test-only-stark.patch passes the test cases and same test case is failing for `claro` defaultTheme 2272637-24-test-only-claro.patch.
Not sure what's wrong with claro theme.

@bnjmnm
Would it be possible for you to double-check the behavior in seven and stark themes?

The last submitted patch, 24: 2272637-24-test-only-claro.patch, failed testing. View results

prasanth_kp’s picture

StatusFileSize
new11.34 KB
new11.66 KB

#24 Patch Applied on 9.5.x and it works fine.

Bushra Shaikh’s picture

StatusFileSize
new66.02 KB

I verified the patch #24 on the drupal 9.5.x version. The patch applied successfully and worked fine.

Testing Results: The state of the checkbox in the DISPLAY column: is checked.
Can be moved to RTBC

RTBC+1

ameymudras’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the patch, I tested #24 on 9.5.x and the following are my findings:

1. The issue summary is clear and steps to reproduce have been given
2. Was able to reproduce the issue on 9.5.x
3. The patch provided applies cleanly and seems to fix the issue. The file visibility setting seems to be consistent
4. Tests have been included and test only patch is failing
5. No issues identified with code review

Marking the issue as RTBC, not including additional screenshots, they have been provided in #26

The last submitted patch, 24: 2272637-24-test-only-claro.patch, failed testing. View results

xjm’s picture

Thanks for working on this issue.

The feedback in #24 is valid and has not been addressed. If this only fails in Claro (as per the patches provided), the test needs to use Claro, or it isn't testing anything.

I also think asking for a frontend framework manager to weigh in on why this is different between themes -- is this a bug in Claro? Would a different fix be better? Etc.

xjm’s picture

Status: Reviewed & tested by the community » Needs work
larowlan’s picture

I looked at Claro and found it has a file-widget-multiple.html.twig but that doesn't look to be doing anything spurious.

However there's a lot going on in claro_preprocess_file_widget_multiple, including looping over the table rows/cells by reference.

I wonder if this bug occurs with that function commented out. If it doesn't then I think the fix should be there rather than in the FileWidget.

mohit++ for the two tests showing the bug exists in claro but not in stark.

bnjmnm’s picture

Confirmed this is specific to Claro, and I'm 95% sure it is happening in _claro_preprocess_file_and_image_widget. It restructures the render array and I'm not sure it's accounting for this value at all, which I believe is in $element["#value"]["display"]

mohit_aghera’s picture

Status: Needs work » Needs review
StatusFileSize
new2.93 KB

Based on feedback from #32 and #33 removing the change from file module and moving fix the claro theme.

For now, I have added test case into file module itself.

mohit_aghera’s picture

StatusFileSize
new2.93 KB
new5.76 KB

Oops, forgot to upload interdiff.
Re-uploading patch along with interdiff.

Hiding the patch in #34 and #24 as both of them are not relevant.

Status: Needs review » Needs work

The last submitted patch, 35: 2272637-34.patch, failed testing. View results

mohit_aghera’s picture

Status: Needs work » Needs review
StatusFileSize
new4.92 KB
new5.14 KB

Attempting the test case failures and doing code change accordingly.
Both the failing tests are passing on local now.

larowlan’s picture

Status: Needs review » Needs work
Issue tags: -Needs frontend framework manager review

Looking good, we can remove the frontend framework manager review tag now we've isolated this to Claro.

Just some minor nits on the test

  1. +++ b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetClaroThemeTest.php
    @@ -0,0 +1,95 @@
    + * We are intentionally testing it with claro default theme to test the few
    + * changes added in _claro_preprocess_file_and_image_widget().
    

    nit `Claro as the` (capital C and added as the), probably can remove the word 'few' too

  2. +++ b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetClaroThemeTest.php
    @@ -0,0 +1,95 @@
    +  protected function setUp(): void {
    +    parent::setUp();
    +  }
    ...
    +  public function testWidgetDefaultVisibilitySettings() {
    

    Not needed anymore?

  3. +++ b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetClaroThemeTest.php
    @@ -0,0 +1,95 @@
    +    $title = $this->randomString();
    ...
    +    $title = $this->randomString();
    

    Let's use randomMachineName instead, string includes things like &, > and < and can therefore cause some random failures with CSS selectors (not relevant now, but could become later)

  4. +++ b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetClaroThemeTest.php
    @@ -0,0 +1,95 @@
    +    $type = $page->find('css', "input[name='{$field_name}[0][display]']")->getAttribute('type');
    

    Can we use $this->assertSession->fieldExists() instead

  5. +++ b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetClaroThemeTest.php
    @@ -0,0 +1,95 @@
    +    $assert_session->checkboxChecked("{$field_name}[0][display]");
    ...
    +    $assert_session->checkboxNotChecked("{$field_name}[0][display]");
    ...
    +    $assert_session->checkboxChecked("{$field_name}[0][display]");
    

    Would be good to also assert the data is stored correctly in the field on the $node, in addition to asserting it shows correctly in the form

  6. +++ b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetClaroThemeTest.php
    @@ -0,0 +1,95 @@
    +    // Disable the field settings and ensure that settings are updated on form.
    

    Missing a word here, perhaps on 'the' form?

  7. +++ b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetClaroThemeTest.php
    @@ -0,0 +1,95 @@
    +    $node = $this->drupalGetNodeByTitle($title);
    

    I don't think you need to call this again as its the same node?

pooja saraah’s picture

StatusFileSize
new4.92 KB
new2.43 KB

Addressed the comment #38-point 1 and 6
Keeping it in Needs Work to address the point 2,3,4,5 and 7
Attached patch and interdiff for #38

ankithashetty’s picture

Status: Needs work » Needs review
StatusFileSize
new5.13 KB
new5.41 KB
new4.91 KB

Addressed the suggestions made in #38.

1. Comment updated.
2. Removed the setUp()
3. Changed to randomMachineName().
4. Replaced with $this->assertSession->fieldExists().
5. Added assert to $node->get($field_name)->value.
6. Comment updated.
7. No code change was done to address this point in the patch. I believe we need to call $node = $this->drupalGetNodeByTitle($title); again after every form submit, to get the latest data stored in the DB for the node.

Please review.
Thanks!

Status: Needs review » Needs work

The last submitted patch, 40: 2272637-40.patch, failed testing. View results

ankithashetty’s picture

Status: Needs work » Needs review
StatusFileSize
new5.13 KB
new1.52 KB

Fixed the phpunit test errors in #40, thanks!

Status: Needs review » Needs work

The last submitted patch, 42: 2272637-42.patch, failed testing. View results

connbi’s picture

#16 the patch is work for me, and the patch which modify the claro.theme is wrong, if user unchecked the Include file in display, the checkbox will always checked.
and the #16 patch is also work on drupal 10, I think the root cause is display not set default value, not in claro theme.

mohit_aghera’s picture

Status: Needs work » Needs review
StatusFileSize
new6.42 KB
new6.09 KB

- Refactoring the implementation little bit so we can easily extend for other themes if required.
- Now we are calculating the values in field widget and setting in claro theme.

Patch in #43 had a few failures.
Addressed those as well.

$node = $this->drupalGetNodeByTitle($title);
We need to call it with each submit with second argument as `TRUE`, so it pulls latest values from the database rather than cache.

Tests are passing on local now.

Status: Needs review » Needs work

The last submitted patch, 45: 2272637-45.patch, failed testing. View results

mohit_aghera’s picture

Version: 9.5.x-dev » 11.x-dev
Status: Needs work » Needs review
StatusFileSize
new6.47 KB
new741 bytes

Fixing the test case failures.
Tests are passing on local now.

smustgrave’s picture

Could the issue summary be updated to include proposed solution too.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Per #48

mohit_aghera’s picture

Issue summary: View changes
mohit_aghera’s picture

Status: Needs work » Needs review
Issue tags: -Needs issue summary update
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Verified the issue following the steps in the issue summary.
Applied patch #47
Verified that the Include file in display is now defaulted to check.

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs screenshots

Thanks everyone for working on this. It's close!

@smustgrave, to get credit for manual testing, you should post before and after screenshots as described in the contributor task doc. Once the patch is updated with my feedback, that will be a good time for someone to provide screenshots, since there have been eight different patch versions and nine months since the most recent screenshots.

  1. +++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
    @@ -321,7 +321,12 @@ public static function value($element, $input, FormStateInterface $form_state) {
    +        if (empty($input['fids'])) {
    +          $input['display'] = $element['#display_default'];
    +        }
    +        else {
    +          $input['display'] = $element['#display_field'] ? 0 : 1;
    +        }
    

    I think we need to expand the inline documentation here a little, since the previous comment clearly wasn't enough to write the right code. One inline comment for the if and one for the else, I expect.

  2. +++ b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetClaroThemeTest.php
    @@ -0,0 +1,100 @@
    + * We are intentionally testing it with Claro as the default theme to test the
    + * changes added in _claro_preprocess_file_and_image_widget().
    

    This is really nitpicky, but we usually shouldn't refer to "we" (or "you"). It's better to make parts of Drupal the subjects of sentences, or simple passive voice as a last resort.

    Here, we can say:

    The widget is tested with Claro as the default theme to test the [...etc.]

    Also, we should add an @see to that underscore-namespaced preprocess further down in the docblock.

  3. +++ b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetClaroThemeTest.php
    @@ -0,0 +1,100 @@
    +   * Tests that visibility settings from field widget are followed on the form.
    

    "Followed" confused me here. "Respected" maybe?

    Also, it's missing the word "the". I understand we're pushing 80 chars, but we can rearrange the sentence a little:

    Tests that the field widget visibility settings are respected on the form.

  4. +++ b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetClaroThemeTest.php
    @@ -0,0 +1,100 @@
    +    $type_name = 'article';
    +    $field_name = 'test_file_field_1';
    +    $field_storage_settings = [
    +      'display_field' => TRUE,
    +      'display_default' => TRUE,
    +    ];
    +    $field_settings = [];
    +    $widget_settings = [];
    +    $field_storage = $this->createFileField($field_name, 'node', $type_name, $field_storage_settings, $field_settings, $widget_settings);
    +
    +    $page = $this->getSession()->getPage();
    +    $assert_session = $this->assertSession();
    +
    +    $test_file = current($this->getTestFiles('text'));
    +    $test_file_path = \Drupal::service('file_system')->realpath($test_file->uri);
    +
    +    $this->drupalGet("node/add/$type_name");
    

    Not a hard requirement, just a suggestion: A couple inline comments for each "paragraph" of code here would make it easier for folks to parse the code in their minds.

  5. +++ b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetClaroThemeTest.php
    @@ -0,0 +1,100 @@
    +    $title = $this->randomMachineName();
    ...
    +    $title = $this->randomMachineName();
    

    Can we use a meaningful test title in each case rather than randomMachineName()? If we want to test specific characters, we should add tests for those characters. In this case, however, we just want a title, and it can describe the purpose of the item under test. (@larowlan is correct that randomString() here would be very bad, but a string literal is better and more readable than randomMachineName() in this context as well.)

  6. +++ b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetClaroThemeTest.php
    @@ -0,0 +1,100 @@
    +    // Now submit the same form and ensure that value is retained.
    

    Very-ultra-nit: There should be a comma after "Now".

  7. +++ b/core/themes/claro/claro.theme
    @@ -1382,6 +1382,11 @@ function _claro_preprocess_file_and_image_widget(array &$variables) {
    +  // Handle the default checkbox display after file is uploaded.
    

    Nit: "...after the file is uploaded."

ashley_herodev’s picture

I've just start looking into it, I should be able to provide some feedback to comment #53 soon

ashley_herodev’s picture

Status: Needs work » Needs review
Issue tags: +Novice
StatusFileSize
new63 bytes
new3.78 KB
new21.02 KB
new18.75 KB

Added screenshots before and after and addressed items on #53 comment

gauravvvv’s picture

StatusFileSize
new6.6 KB
new3.64 KB

Addressed feedback from #53, attached patch with interdiff. please review

gauravvvv’s picture

StatusFileSize
new6.6 KB
new642 bytes

Fixed CC failure issue

ashley_herodev’s picture

Thanks @Gauravvvv for applying the interdiff file 47-55 and recreate the patch for me

smustgrave’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs screenshots

@Gauravvvv this was tagged for novice/new users. Based on your git posts that would not include you :). Please leave novice issues alone for new users.

But what done is done.

Took the screenshots from #55 and added to the IS.

xjm’s picture

Status: Reviewed & tested by the community » Needs work
  1. #53.1 was not addressed, oops!
     

  2. +++ b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetClaroThemeTest.php
    @@ -7,9 +7,11 @@
    + * The widget is intentionally tested with Claro as the default theme to test the
    

    This is 81 characters. :) Drupal has a character limit of 80 characters on code comments, so this comment now needs to be rewrapped.

  3. +++ b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetClaroThemeTest.php
    @@ -20,9 +22,10 @@ class FileFieldWidgetClaroThemeTest extends FileFieldWidgetTest {
    +    // Given the initial data below
    
    @@ -39,8 +42,9 @@ public function testWidgetDefaultVisibilitySettings(): void {
    +    // Filling the form accordingly
    

    Drupal inline comments have to be complete sentences (with periods at the end). So for the first comment, I would change it to describe what's important about the data. Something like:

    Set up an article node with whatever whatever about the display settings.

    The second can be:

    Fill out the form accordingly.

ashley_herodev’s picture

Status: Needs work » Needs review
StatusFileSize
new7.14 KB
new2.86 KB

Adressed comment #60

ashley_herodev’s picture

Fixing the patch in a few moments

ashley_herodev’s picture

StatusFileSize
new7 KB
new2.81 KB

The patch failed to apply due to trailing whitespace, but since I didn't find any whitespace locally I suspected of an EOL issue. So I just converted CR LF to LF

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Looking much better, good catch with the line endings

agoradesign’s picture

works for me (Drupal 10.1.5 + Gin Admin Theme)

xjm’s picture

Saving issue credits. @smustgrave is credited for mentoring (the small issue management tasks themselves weren't quite to creditable, but the mentoring is). @bnjmnm, @larowlan, and myself are credited for code reviews etc.

@ameymudras' earlier RTBC comment is kind of borderline -- I'm going to credit it here since it helped sum up some things that were lost in the noise back in January, but in the future I'd recommend doing your own code review and documenting more specific thoughts or steps you had during the code review. (Also, mentioning that you tested with the steps in the IS and exactly what changed from before to after, in words, is helpful even if the screenshots are already provided -- since no one had actually really said that yet when uploading all the duplicate screenshots.)

@pooja saraah, it looks like you've been able to contribute to numerous core issues already -- nice work! Going forward, it would be good to see you addressing the full review (rather than just the easiest points from it) in order to receive issue credit.

@Gauravvvv, you mostly duplicated @ashley_herodev's work in #55. Normally, I would not add credit for this; however, since @ashley_herodev was having some issues with patch encoding, I'll credit it this once. In the future, duplicating an existing patch or small changes like fixing a reroll will not receive credit since you've already made extensive contributions and aren't really a novice anymore. :)

@Arun Velusamy, @Jaykumar95, @Arti Anil Pattewar, @prasanth_kp, and @Bushra Shaikh do not receive credit since they either duplicated previous manual testing or did not provide sufficient explanation and illustration of their manual testing.

  • xjm committed 41668b6b on 11.x
    Issue #2272637 by mohit_aghera, ashley_herodev, ankithashetty, Gauravvvv...

  • xjm committed 4f214398 on 10.2.x
    Issue #2272637 by mohit_aghera, ashley_herodev, ankithashetty, Gauravvvv...

  • xjm committed 70dcf6dd on 10.1.x
    Issue #2272637 by mohit_aghera, ashley_herodev, ankithashetty, Gauravvvv...
xjm’s picture

Version: 11.x-dev » 10.1.x-dev

Committed to 11.x, 10.2.x, and 10.1.x as a patch-safe, non-disruptive bugfix. Thanks everyone!

Fixed on commit: some super-small nitpicks that I missed in my previous reviews.

diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
index 29abb041432..c97a4d20b38 100644
--- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
+++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
@@ -325,7 +325,7 @@ public static function value($element, $input, FormStateInterface $form_state) {
           $input['display'] = $element['#display_default'];
         }
         // Checkboxes lose their value when empty.
-        // If the display field is present make sure its unchecked value is
+        // If the display field is present, make sure its unchecked value is
         // saved.
         else {
           $input['display'] = $element['#display_field'] ? 0 : 1;
diff --git a/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetClaroThemeTest.php b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetClaroThemeTest.php
index af2cd7ec6ce..69bbaf3bf1e 100644
--- a/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetClaroThemeTest.php
+++ b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetClaroThemeTest.php
@@ -5,7 +5,7 @@
 use Drupal\Core\Url;
 
 /**
- * Tests the widget visibility settings for Claro theme.
+ * Tests the widget visibility settings for the Claro theme.
  *
  * The widget is intentionally tested with Claro as the default theme to test
  * the changes added in _claro_preprocess_file_and_image_widget().
@@ -25,7 +25,7 @@ class FileFieldWidgetClaroThemeTest extends FileFieldWidgetTest {
    * Tests that the field widget visibility settings are respected on the form.
    */
   public function testWidgetDefaultVisibilitySettings(): void {
-    // Set up an article node with all field storage settings as true.
+    // Set up an article node with all field storage settings set to TRUE.
     $type_name = 'article';
     $field_name = 'test_file_field_1';
     $field_storage_settings = [
@@ -69,7 +69,7 @@ public function testWidgetDefaultVisibilitySettings(): void {
     $this->drupalGet(Url::fromRoute('entity.node.edit_form', ['node' => $node->id()]));
     $assert_session->checkboxNotChecked("{$field_name}[0][display]");
 
-    // Disable the field settings and ensure that settings are updated on form.
+    // Disable the field settings and ensure that the form is updated.
     $field_storage->setSetting('display_default', FALSE);
     $field_storage->save();
     $page = $this->getSession()->getPage();
@@ -84,14 +84,14 @@ public function testWidgetDefaultVisibilitySettings(): void {
     $this->assertEquals($type, 'checkbox');
     $assert_session->checkboxNotChecked("{$field_name}[0][display]");
 
-    // Now submit the same form and ensure that value is retained.
+    // Submit the same form and ensure that value is retained.
     $this->submitForm([], 'Save');
     $node = $this->drupalGetNodeByTitle($title, TRUE);
     $this->assertEquals(0, $node->get($field_name)->getValue()[0]['display'], 'The checkbox is disabled.');
     $this->drupalGet(Url::fromRoute('entity.node.edit_form', ['node' => $node->id()]));
     $assert_session->checkboxNotChecked("{$field_name}[0][display]");
 
-    // Now check the checkbox and ensure that it is submitted properly.
+    // Check the checkbox and ensure that it is submitted properly.
     $this->submitForm([
       "{$field_name}[0][display]" => TRUE,
     ], 'Save');
xjm’s picture

Status: Reviewed & tested by the community » Fixed
needs-review-queue-bot’s picture

Status: Fixed » Needs work

The Needs Review Queue Bot tested this issue.

While you are making the above changes, we recommend that you convert this patch to a merge request. Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)

nod_’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.