Skip to content
Snippets Groups Projects
Verified Commit 4dd544e7 authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3419621 by dburiak, sijumpk, smustgrave, pameeela, alexpott:...

Issue #3419621 by dburiak, sijumpk, smustgrave, pameeela, alexpott: tablePositionSticky should not be called on a non-array variable

(cherry picked from commit 7e28ed51)
parent 24a5b5a5
No related branches found
No related tags found
5 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type"
Pipeline #140639 passed
Pipeline: drupal

#140673

    Pipeline: drupal

    #140662

      Pipeline: drupal

      #140654

        +1
        ......@@ -2,6 +2,7 @@
        namespace Drupal\KernelTests\Core\Theme;
        use Drupal\claro\ClaroPreRender;
        use Drupal\KernelTests\KernelTestBase;
        /**
        ......@@ -38,4 +39,35 @@ public function testThemeTableStickyHeaders() {
        $this->assertRaw('position-sticky');
        }
        /**
        * Confirm Claro prerender callback is not executed for non-array class.
        */
        public function testThemeTablePositionStickyPreRender(): void {
        // Enable the Claro theme.
        \Drupal::service('theme_installer')->install(['claro']);
        $this->config('system.theme')->set('default', 'claro')->save();
        $header = ['one', 'two', 'three'];
        $rows = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
        $table = [
        '#type' => 'table',
        '#header' => $header,
        '#rows' => $rows,
        '#sticky' => TRUE,
        '#attributes' => [
        'class' => 'class',
        ],
        '#pre_render' => [
        [
        ClaroPreRender::class,
        'tablePositionSticky',
        ],
        ],
        ];
        $renderedTable = \Drupal::service('renderer')->renderRoot($table);
        // Confirm that table is rendered.
        $this->assertStringContainsString('class="class"', $renderedTable);
        }
        }
        ......@@ -193,7 +193,7 @@ public static function messagePlaceholder(array $element) {
        * Prerender callback for table elements.
        */
        public static function tablePositionSticky(array $element) {
        if (isset($element['#attributes']['class']) && in_array('sticky-enabled', $element['#attributes']['class'])) {
        if (isset($element['#attributes']['class']) && is_array($element['#attributes']['class']) && in_array('sticky-enabled', $element['#attributes']['class'], TRUE)) {
        unset($element['#attributes']['class'][array_search('sticky-enabled', $element['#attributes']['class'])]);
        $element['#attributes']['class'][] = 'position-sticky';
        }
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment