Skip to content
Snippets Groups Projects
Verified Commit 5b240ef4 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2998857 by Luke.Leber, e.chatrer, afem, bskibinski, mgifford: a11y:...

Issue #2998857 by Luke.Leber, e.chatrer, afem, bskibinski, mgifford: a11y: Input type file fields lack aria-describedby to the description

(cherry picked from commit 74b6ceda)
parent 8f08ecc0
Branches
Tags
5 merge requests!122353526426-warning-for-missing,!11958Issue #3490507 by alexpott, smustgrave: Fix bogus mocking in...,!11769Issue #3517987: Add option to contextual filters to encode slashes in query parameter.,!11185Issue #3477324 by andypost, alexpott: Fix usage of str_getcsv() and fgetcsv() for PHP 8.4,!9944Issue #3483353: Consider making the createCopy config action optionally fail...
Pipeline #220586 passed
Pipeline: drupal

#220615

    Pipeline: drupal

    #220608

      Pipeline: drupal

      #220601

        +1
        ......@@ -320,6 +320,11 @@ public static function processManagedFile(&$element, FormStateInterface $form_st
        '#weight' => -10,
        '#error_no_message' => TRUE,
        ];
        if (!empty($element['#description'])) {
        $element['upload']['#attributes']['aria-describedby'] = $element['#id'] . '--description';
        }
        if (!empty($element['#accept'])) {
        $element['upload']['#attributes'] = ['accept' => $element['#accept']];
        }
        ......
        ......@@ -41,6 +41,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $tree = T
        $form['nested']['file'] = [
        '#type' => 'managed_file',
        '#title' => $this->t('Managed <em>@type</em>', ['@type' => 'file & butter']),
        '#description' => $this->t('Upload a <em>@type</em> file', ['@type' => 'file & butter']),
        '#upload_location' => 'public://test',
        '#progress_message' => $this->t('Processing...'),
        '#extended' => (bool) $extended,
        ......
        ......@@ -4,6 +4,7 @@
        namespace Drupal\Tests\file\Functional;
        use Drupal\Component\Utility\Html;
        use Drupal\file\Entity\File;
        /**
        ......@@ -40,8 +41,14 @@ public function testManagedFile(): void {
        $input_base_name = $tree ? 'nested_file' : 'file';
        $file_field_name = $multiple ? 'files[' . $input_base_name . '][]' : 'files[' . $input_base_name . ']';
        // Submit without a file.
        $this->drupalGet($path);
        // Ensure the aria-describedby relationship works as expected.
        $input_id = Html::getId('edit_' . $input_base_name);
        $this->assertSession()->elementExists('css', '#' . $input_id . '--description');
        $this->assertSession()->elementExists('css', '[aria-describedby="' . $input_id . '--description"]');
        // Submit without a file.
        $this->submitForm([], 'Save');
        $this->assertSession()->pageTextContains("The file ids are .");
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment