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

Issue #2977950 by Lendude, smustgrave, lauriii: Move the bc layer for views UI...

Issue #2977950 by Lendude, smustgrave, lauriii: Move the bc layer for views UI CSS classes from views to stable9
parent 02c07301
No related branches found
No related tags found
31 merge requests!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8540Issue #3457061: Bootstrap Modal dialog Not closing after 10.3.0 Update,!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8373Issue #3427374 by danflanagan8, Vighneshh: taxonomy_tid ViewsArgumentDefault...,!7526Expose roles in response,!7352Draft: Resolve #3203489 "Set filename as",!6791Issue #3163299: Ajax exposed filters not working for multiple instances of the same Views block placed on one page,!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3668Resolve #3347842 "Deprecate the trusted",!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2794Issue #3100732: Allow specifying `meta` data on JSON:API objects,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2334Issue #3228209: Add hasRole() method to AccountInterface,!2062Issue #3246454: Add weekly granularity to views date sort,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #102333 canceled
Pipeline: drupal

#102336

    ...@@ -46,15 +46,15 @@ public function testCssClassCleaning() { ...@@ -46,15 +46,15 @@ public function testCssClassCleaning() {
    $view = Views::getView('test_preprocess'); $view = Views::getView('test_preprocess');
    $build = $view->buildRenderable(); $build = $view->buildRenderable();
    $renderer->renderRoot($build); $renderer->renderRoot($build);
    $this->assertStringContainsString('class="entity-test--default entity-test__default', (string) $build['#markup']); $this->assertStringContainsString('class="entity-test__default', (string) $build['#markup']);
    $view->destroy(); $view->destroy();
    $view->setDisplay('display_2'); $view->setDisplay('display_2');
    $build = $view->buildRenderable(); $build = $view->buildRenderable();
    $renderer->renderRoot($build); $renderer->renderRoot($build);
    $markup = (string) $build['#markup']; $markup = (string) $build['#markup'];
    $this->assertStringContainsString('css_class: entity-test--default and-another-class entity-test__default', $markup); $this->assertStringContainsString('css_class: entity-test__default and-another-class', $markup);
    $this->assertStringContainsString('attributes: class="entity-test--default and-another-class entity-test__default', $markup); $this->assertStringContainsString('attributes: class="entity-test__default and-another-class', $markup);
    } }
    /** /**
    ......
    ...@@ -35,17 +35,10 @@ function template_preprocess_views_view(&$variables) { ...@@ -35,17 +35,10 @@ function template_preprocess_views_view(&$variables) {
    $css_class = $view->display_handler->getOption('css_class'); $css_class = $view->display_handler->getOption('css_class');
    if (!empty($css_class)) { if (!empty($css_class)) {
    // Views uses its own sanitization method. This is preserved to keep
    // backwards compatibility.
    // @todo https://www.drupal.org/project/drupal/issues/2977950 Decide what to
    // do with the backwards compatibility layer.
    $bc_classes = explode(' ', preg_replace('/[^a-zA-Z0-9- ]/', '-', $css_class));
    // Sanitize the classes using the classes using the proper API.
    $sanitized_classes = array_map('\Drupal\Component\Utility\Html::cleanCssIdentifier', explode(' ', $css_class)); $sanitized_classes = array_map('\Drupal\Component\Utility\Html::cleanCssIdentifier', explode(' ', $css_class));
    $view_classes = array_unique(array_merge($bc_classes, $sanitized_classes));
    // Merge the view display classes into any existing classes if they exist. // Merge the view display classes into any existing classes if they exist.
    $variables['attributes']['class'] = !empty($variables['attributes']['class']) ? array_merge($variables['attributes']['class'], $view_classes) : $view_classes; $variables['attributes']['class'] = !empty($variables['attributes']['class']) ? array_merge($variables['attributes']['class'], $sanitized_classes) : $sanitized_classes;
    $variables['css_class'] = implode(' ', $view_classes); $variables['css_class'] = implode(' ', $sanitized_classes);
    } }
    // contextual_preprocess() only works on render elements, and since this theme // contextual_preprocess() only works on render elements, and since this theme
    ......
    ...@@ -15,3 +15,20 @@ function stable9_preprocess_item_list__search_results(&$variables) { ...@@ -15,3 +15,20 @@ function stable9_preprocess_item_list__search_results(&$variables) {
    $variables['empty']['#tag'] = 'h3'; $variables['empty']['#tag'] = 'h3';
    } }
    } }
    /**
    * Implements hook_preprocess_views_view().
    *
    * Adds BC classes that were previously added by the Views module.
    */
    function stable9_preprocess_views_view(&$variables) {
    if (!empty($variables['attributes']['class'])) {
    $bc_classes = preg_replace('/[^a-zA-Z0-9- ]/', '-', $variables['attributes']['class']);
    $variables['attributes']['class'] = array_merge($variables['attributes']['class'], $bc_classes);
    }
    if (!empty($variables['css_class'])) {
    $existing_classes = explode(' ', $variables['css_class']);
    $bc_classes = preg_replace('/[^a-zA-Z0-9- ]/', '-', $existing_classes);
    $variables['css_class'] = implode(' ', array_merge($existing_classes, $bc_classes));
    }
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment