Commit 9985cc04 authored by Jess's avatar Jess
Browse files

Issue #3041143 by tim.plunkett, cboyden, xjm, phenaproxima, rainbreaw: Add...

Issue #3041143 by tim.plunkett, cboyden, xjm, phenaproxima, rainbreaw: Add ARIA group roles to Layout Builder UI
parent e59ec93f
Loading
Loading
Loading
Loading
+7 −0
Changes for core/modules/layout_builder/src/Element/LayoutBuilder.php: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -285,6 +285,11 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s
      $build[$region]['layout_builder_add_block']['#weight'] = 1000;
      $build[$region]['#attributes']['data-region'] = $region;
      $build[$region]['#attributes']['class'][] = 'layout-builder__region';
      $build[$region]['#attributes']['role'] = 'group';
      $build[$region]['#attributes']['aria-label'] = $this->t('@region region in section @section', [
        '@region' => $info['label'],
        '@section' => $delta + 1,
      ]);
    }

    $build['#attributes']['data-layout-update-url'] = Url::fromRoute('layout_builder.move_block', [
@@ -298,6 +303,8 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s
      '#type' => 'container',
      '#attributes' => [
        'class' => ['layout-builder__section'],
        'role' => 'group',
        'aria-label' => $this->t('Section @section', ['@section' => $delta + 1]),
      ],
      'remove' => [
        '#type' => 'link',
+10 −0
Changes for core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -328,6 +328,16 @@ public function testLayoutBuilderUi() {
    $this->drupalGet("$field_ui_prefix/display/default/layout");
    $assert_session->pageTextNotContains('My text field');
    $assert_session->elementNotExists('css', '.field--name-field-my-text');

    $expected_labels = [
      'Section 1',
      'Content region in section 1',
    ];
    $labels = [];
    foreach ($page->findAll('css', '[role="group"]') as $element) {
      $labels[] = $element->getAttribute('aria-label');
    }
    $this->assertSame($expected_labels, $labels);
  }

  /**