Problem/Motivation

Currently, we are checking if cookies for the specific service are accepted on the view preprocess to not render placeholder if it's not needed.

    // Gets cookies from the current request.
    $cookies = \Drupal::requestStack()
      ->getCurrentRequest()
      ->cookies
      ->get('cookiesjsr');
    // Checks if current service cookies accepted.
    // If it's accepted, then we don't need to add a placeholder, just let
    // view render as it is.
    if ($cookies && isset(json_decode($cookies)->$service)) {
      return;
    }

I'd like to suggest moving this validation on a step earlier to prevent breaking Ajax functionality for the view, which is JS probably caused. So, we'll check if cookies are accepted in the _cookies_addons_views_is_restricted() function instead.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

_shY created an issue. See original summary.

_shy’s picture

Status: Active » Needs review
_shy’s picture

Component: Code » Cookies Addons Views
guido_s’s picture

Status: Needs review » Reviewed & tested by the community

Good point.
I checked the merge request.
Code makes sense to me.
I only suggested small changes for the comments to improve grammar and understandability.

  • _shY committed e0e288f6 on 1.0.x
    Issue #3425420: Improvements for the view cookies module restriction...
_shy’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.