Problem/Motivation

Default vs. Full is weird, there are a number of issues around that and the main problem is that getViewModeOptionsByBundle() and related methods return wrong data.

The default view mode is "full", which if not explicitly enabled will then fall back to the configuration provided by "Default". But the $view_mode argument *is* full.

One example where this breaks is if you have a node--$type--full.html.twig template, but the preview doesn't use that.

Proposed resolution

Changing those methods is hard, especially in 8.x. The patch that I will attach proposes a very simply workaround, we simply add Full sa the first option in the list, always.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

Berdir’s picture

Status: Active » Needs review
FileSize
868 bytes
Berdir’s picture

We also need to set the default to full. Not sure if we should remove default completely or not. IMHO yes.

Status: Needs review » Needs work

The last submitted patch, 3: node-preview-full-default-2834316-3.patch, failed testing.

Berdir’s picture

Updated the tests. Seems to me we don't really need additional test coverage if we agree that this change makes sense conceptually. And I really think so :)

Status: Needs review » Needs work

The last submitted patch, 5: node-preview-full-default-2834316-5.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review

Same random test fail.

claudiu.cristea’s picture

Hm, at least for me now looks more confusing having both "Full" and "Default" in the dropdown list. I have to confess that it took me a while in the past to familiarize with the difference between Default and Full.

swentel’s picture

Status: Needs review » Reviewed & tested by the community

Makes sense to me.

Berdir’s picture

Version: 8.2.x-dev » 8.3.x-dev

Re full vs default. I'd be happy to remove default completely but I wasn't sure about whether that is an OK change, especially for a patch release. But I'd be OK to remove default and only get it into 8.3.x in turn.

This will definitely fail/conflict now on 8.3.x now, though.

Also, I plan to open an issue to make sense of the default/full/fallback confusion in general, but pretty sure that is 9.x material.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 5: node-preview-full-default-2834316-5.patch, failed testing.

Berdir’s picture

Reroll for 8.3.x, updated tests and completely removing "Default" as suggested in #10 that might be OK for an 8.3 only patch.

claudiu.cristea’s picture

Looks good. Just a very minor nit

+++ b/core/modules/node/src/Form/NodePreviewForm.php
@@ -85,9 +85,11 @@ public function buildForm(array $form, FormStateInterface $form_state, EntityInt
+    $view_mode_options = ['full' => t('Full')] + $this->entityManager->getViewModeOptionsByBundle('node', $node->bundle());

FormBase is already using the StringTranslationTrait, so $this->t() is available. s/t()/$this->t()

Berdir’s picture

claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Needs review

What happens when the full mode is deleted? I tried this locally and everything works - it just falls back to default but I'm not sure that adding full makes sense if it doesn't exist.

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Even if you delete* "full", that's still the view mode that is used on node/1.

View mode config entities really only have one purpose, to show up as a checkboxes on "Manage display", so you can enable a display for it. At runtime, the view mode is just a string, it is never loaded/validated or anything.

* Yes, you probably shouldn't be able to delete that, but that's another story. I also plan to create a follow-up issue to bring sense into the whole default/full view mode/view display mess.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 959df8d to 8.3.x and 333a973 to 8.2.x. Thanks!

Discussed with @Berdir in IRC and we decided that this makes things better since as @Berdir wrote:

it is all very weird. and even our own API is completely wrong about default/full, which of course doesn't help with actually understand what view modes/view displays are and results in all our UI's being wrong :)

based on discussions with slashrsm and others, I'm thinking about just making "Full" the fallback or maybe drop the fallback concept completely (no view display enabled => no pre-configured fields), but those are 9.x changes..

yeah. I can live with entity reference formatters and views being wrong about default/full, but you almost never use either default or full in those cases, so easy to ignore. node preview is different though because is the default selection and what you actually want to see in most cases

  • alexpott committed 959df8d on 8.3.x
    Issue #2834316 by Berdir, claudiu.cristea: Node preview shows and...

  • alexpott committed 333a973 on 8.2.x
    Issue #2834316 by Berdir, claudiu.cristea: Node preview shows and...
Berdir’s picture

  • alexpott committed 959df8d on 8.4.x
    Issue #2834316 by Berdir, claudiu.cristea: Node preview shows and...

  • alexpott committed 959df8d on 8.4.x
    Issue #2834316 by Berdir, claudiu.cristea: Node preview shows and...

Status: Fixed » Closed (fixed)

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