Problem/Motivation

Currently, when you use the View Mode Switch Field for paragraphs that are added with the experimental widget and Preview as closed mode, a potential view mode switch change for the Preview view mode is not outputted correctly.

Steps to reproduce

  • Create a paragraph type with View Mode Switch Field, that switches the Preview mode
  • Configure the paragraph type's Preview display and any other displays that the Preview view mode is allowed to switch to via View Mode Switch Field
  • Create an entity reference revisions field for paragraphs e.g. on a node type
  • Configure the experimental widget for the paragraphs field to use Preview as closed mode
  • Create an entity of the type you added the paragraphs field to and change between paragraph's edit form and its preview while changing the View Mode Switch field... you will see that only the initial view mode switch is respected and outputted

Proposed resolution

  • Always output the correct view mode that may have been switched to in paragraph widget's Preview closed mode

Remaining tasks

  • Provide a fix for preview handling in ViewModeSwitch::getViewModeToSwitchTo()

User interface changes

n/a

API changes

n/a

Data model changes

n/a

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

hctom created an issue. See original summary.

hctom’s picture

Title: Preview is not correct for paragraphs » Preview with changed view mode is not correct for paragraph's experimental widget
hctom’s picture

Version: 8.x-1.x-dev » 2.x-dev

hctom’s picture

This issue should be fixed. From now on most common preview cases will work without caching, so there is always the correct view mode displayed. The test-only branch was allowed to fail, as it is only there to prove the bug. Its contained functional JavaScript test is added, too (proper unit tests will be added in #3161121: Add unit tests.

  • hctom committed 4eb7905 on 2.x
    Issue #3206382 by hctom: Preview with changed view mode is not correct...
hctom’s picture

Status: Active » Fixed
hctom’s picture

Status: Fixed » Closed (fixed)

hctom’s picture

Fix has also been backported to 8.x-1.x.