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).

Issue fork diff-3541546

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

shaila.amale created an issue. See original summary.

shaila.amale’s picture

StatusFileSize
new3.79 KB
shaila.amale’s picture

StatusFileSize
new3.53 KB

er.garg.karan made their first commit to this issue’s fork.

shaila.amale’s picture

StatusFileSize
new3.47 KB

Updated the patch to fix coding standards issues reported by phpcs. Please review the attached patch..

shaila.amale’s picture

StatusFileSize
new3.98 KB

Updated the patch to fix coding standards issues reported by phpcs.
Please review the attached patch.

shaila.amale’s picture

StatusFileSize
new3.96 KB

Cleaned up non-ASCII characters from the patch. Updated code attached for review.

ashraf.hussain’s picture

StatusFileSize
new3.97 KB

Compatible patch for 2.1.1

ashraf.hussain changed the visibility of the branch 3541546-always-display-fields-revision to hidden.

ashraf.hussain changed the visibility of the branch 3541546-always-display-fields-revision to active.

ashraf.hussain’s picture

StatusFileSize
new3.97 KB

Compatible patch for 2.1.1 with minor improvements.

acbramley’s picture

Version: 8.x-1.9 » 2.x-dev
Status: Active » Needs work
ashraf.hussain’s picture

StatusFileSize
new4.48 KB
ashraf.hussain’s picture

@acbramley, Thanks for checking, I have fixed the Phpunit issues, but MR Pipeline is failing in composer install due to a Composer dev-dependency conflict, not because of this patch.
https://git.drupalcode.org/issue/diff-3541546/-/pipelines/929339
https://git.drupalcode.org/issue/diff-3541546/-/jobs/11650811

acbramley’s picture

@ashraf.hussain rebase your branches and that'll be fixed.