Add "Always Display Fields" option to Diff module for API-first/headless sites without Entity View Display

Created on 15 August 2025, 1 day ago

Problem/Motivation

The Diff module currently only compares fields that are marked as displayable in the Entity View Display. This works fine for traditional Drupal sites where fields are rendered through display modes.

However, in API-first or headless Drupal setups, some or all fields may not have an Entity View Display configuration at all — for example:

Content is delivered entirely through JSON:API or GraphQL.

Fields are intentionally hidden from the rendered display to reduce HTML output.

Some entity types (e.g., certain Paragraphs or custom entities) do not have view modes configured.

In these cases, Diff will treat those fields as hidden and exclude them from comparisons, even though they exist and contain data.

Steps to reproduce

Install and enable Diff module.
Create a content type with multiple fields.
Hide one or more fields in the Entity View Display configuration.
Compare two revisions of a node — hidden fields will not appear in the diff output.

Proposed resolution

Add a new configuration option to Diff settings:

Always treat fields as displayable
If enabled, the Diff module will compare all fields regardless of Entity View Display settings. Useful for API-first/headless sites.

Implementation details:

Added always_display_fields boolean to diff.settings.yml (default false).

Updated DiffBuilderManager::getSelectedPluginForFieldStorageDefinition() and isFieldStorageDefinitionDisplayed() to respect the new setting.

Extended GeneralSettingsForm to include a checkbox for this option.

Remaining tasks

Review code for coding standards (phpcs) and test coverage.

Add automated test to ensure hidden fields are displayed when setting is enabled.

Wait for maintainer feedback and apply any requested changes.

User interface changes

Adds a new checkbox in Diff → Settings:

Always treat fields as displayable
If enabled, the Diff module will compare all fields regardless of Entity View Display settings

API changes

No public API changes.

Internal: DiffBuilderManager::isFieldStorageDefinitionDisplayed() and getSelectedPluginForFieldStorageDefinition() updated to respect new config setting.

Data model changes

Adds a new boolean config key: always_display_fields in diff.settings.yml.
Default value: false (preserves current behavior).

Feature request
Status

Active

Version

1.9

Component

Code

Created by

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024