Verified Commit d5f7540e authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3495733 by deepali sardana, idebr, knyshuk.vova: ManagedFile #accept...

Issue #3495733 by deepali sardana, idebr, knyshuk.vova: ManagedFile #accept overwrites existing attributes

(cherry picked from commit 55d9324f)
parent f98eac78
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -326,7 +326,7 @@ public static function processManagedFile(&$element, FormStateInterface $form_st
    }

    if (!empty($element['#accept'])) {
      $element['upload']['#attributes'] = ['accept' => $element['#accept']];
      $element['upload']['#attributes']['accept'] = $element['#accept'];
    }

    // Indicate that $element['#title'] should be used as the HTML label for the
+2 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ public function testWidgetElement(): void {
    $min_resolution = 50;
    $max_resolution = 100;
    $field_settings = [
      'description' => 'test description',
      'max_resolution' => $max_resolution . 'x' . $max_resolution,
      'min_resolution' => $min_resolution . 'x' . $min_resolution,
      'alt_field' => 0,
@@ -36,7 +37,7 @@ public function testWidgetElement(): void {
    // Verify that the image field widget is found on add/node page.
    $this->assertSession()->elementExists('xpath', '//div[contains(@class, "field--widget-image-image")]');
    // Verify that the image field widget limits accepted files.
    $this->assertSession()->elementExists('xpath', '//input[contains(@accept, "image/*")]');
    $this->assertSession()->elementExists('xpath', '//input[@aria-describedby][contains(@accept, "image/*")]');
    $this->assertSession()->pageTextNotContains('Image test on [site:name]');

    // Check for allowed image file extensions - default.