Missing placeholder display for blocked content

Created on 19 August 2025, 26 days ago

Problem/Motivation

The cookies_addons_fields module completely removes field content when cookies are not accepted, showing
empty areas instead of informative placeholder messages with "Accept Cookies" buttons. This creates poor
user experience and is inconsistent with other cookie services like cookies_video.

Steps to reproduce

1. Enable cookies_addons_fields module
2. Configure a field (e.g., embedcode) to require video cookie consent
3. Visit page with blocked content without accepting cookies
4. Observe empty/blank area where content should be
5. No placeholder text or accept button is shown

Proposed resolution

Modify cookies_addons_fields_preprocess_field() in cookies_addons_fields.module to keep field content and
let the JavaScript overlay system handle display, similar to how cookies_video works.

Current approach removes content:
$variables['items'] = [];

Proposed approach: Keep content and mark as blocked:
$variables['attributes']['class'][] = 'cookies-addons-fields-blocked';

This allows the cookiesOverlay system to show proper placeholder text and accept buttons.

Remaining tasks

- [ ] Update PHP preprocessing to not remove field items
- [ ] Ensure JavaScript properly handles blocked content display
- [ ] Test placeholder text and accept buttons appear correctly
- [ ] Verify content shows after accepting cookies

User interface changes

- Blocked fields will now show placeholder text instead of empty areas
- "Accept Cookies" buttons will be visible for blocked content
- Consistent experience with other cookie services

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Active

Version

1.3

Component

Cookies Addons Fields

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @scontzen
  • πŸ‡©πŸ‡ͺGermany guido_s Cologne

    Content can't be kept as this what needs to be blocked.
    It must be done somewhat like in cookies_addons_views.
    Thought I had seen something like this in the code when I checked @_shy s code. But as mentioned didn't have the time to check the rendered output myself.
    @_shy said it would be working fine. If not that needs to be fixed. Everything needs a proper placeholder div which is replaced after cookie consent for the specific category.

  • First commit to issue fork.
  • πŸ‡ΊπŸ‡¦Ukraine _shy Ukraine, Lutsk πŸ‡ΊπŸ‡¦

    Created a PR and attached a patch with the changes for easy testing.

  • πŸ‡©πŸ‡ͺGermany guido_s Cologne

    I just tested in Drupal 11.2.3 and can confirm there is a placeholder now on both nodes and blocks, but I also noticed the content of the field isn't blocked now. The placeholder just covers the content of the field.
    So this needs more work.

    <div id="block-olivero-testblockfortestingfieldblockinginblocks" class="block block-block-content block-block-contentbfd273df-2330-489e-be5d-183a295bc5e6">
      
          <h2 class="block__title">Test Block for testing field blocking in blocks</h2>
        
          <div class="block__content">
          
                <div class="cookies-fallback--fields--wrap cookies-fallback--wrap disabled"><div class="cookies-addons-fields-placeholder text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item cookies-fallback--element" data-cookies-service="fields" data-service-name="Fields" data-field-id="block_content-1-body" data-view-mode="full" id="block_content-1-body-content">Test body of blocked field</div><div class="cookies-fallback cookies-fallback--fields cookies-fallback--fields--overlay"><div class="cookies-fallback--text">This content is blocked because field cookies have not been accepted.</div><button class="cookies-fallback--fields--btn cookies-fallback--btn">Accept field cookies</button><a href="#cookiesjsrAccept" class="cookies-fallback--link">Accept All Cookies</a></div></div>
          
        </div>
      </div>
  • πŸ‡ΊπŸ‡¦Ukraine _shy Ukraine, Lutsk πŸ‡ΊπŸ‡¦

    I reworked the PR. Instead of hiding content with a placeholder, I loop through all field items and clear content inside of each.
    This will block content and keep the correct structure to render the placeholder correctly.

    Please, take a look.

Production build 0.71.5 2024