Steps to reproduce:

- Set up a markup field
- Switch a Node types view mode to layout builder
- In lb ui for the view mode (e.g. /admin/structure/types/manage/article/display/default/layout) place a markup field in the content area
- The field shows in lb interface
- Save
- Open a node: Markup Field is not rendered

CommentFileSizeAuthor
#9 3059129-markup-9.patch1.24 KBtim.plunkett

Issue fork markup-3059129

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

anruether created an issue. See original summary.

anybody’s picture

I can confirm this problem! It is indeed incompatible, no content shows up on display.
The reason seems to be that all other fields become a field_block while this field type doesn't.

To be honest I have no clue why... This is a very very simple field and the field formatter seems OK to me...

anruether’s picture

Priority: Normal » Major

Setting to major, because it blocks layout builder being used and we have no workaround. (if I understand priority levels correctly - maintainers aren't whatching anyways, but....)

At some point we might look into this more thouroughly, but I can't say when atm..

anybody’s picture

@anruether: I still can't find the reason, this is really annoying. Did you have time to look into that?

viewElements() is definitely called, but the value is lost somewhere on its way ... I have no clue to be honest.

anybody’s picture

After searching for a solution for several hours I believe it's a core issue and not Markup modules fault. We're experiencing strange behaviour also for other fields like node links etc.

I hofe someome will find the reason soon, I'll stop my search now.

anruether’s picture

Thanks for your research! Do you think we should move this to the core (layout builder) issue queue to get some more exposure? Do you want to add steps to reproduce for the node links issue you experienced or would that be a different issue?

anybody’s picture

@anruether, perhaps it wouldn't be wrong to create a separate issue for layout builder in core issue que and reference this issue. First of all you should also have a look at that issue que, I couldn't find a matching issue. The node links issue might be different and is not that easy to reproduce and describe, because it doesn't appear for default view mode, so let's better keep this simple.

Furthermore we're already using two core patches which may have side-effects so I guess it's best to describe only THIS problem with a very simple default Drupal 8 installation after testing it before, for example on simplytest.me.

Anyway I'm not 100% sure it's a core issue, but have no more idea what might be wrong in Markup, which is a quite lightweight module...

Over and out :)

anruether’s picture

Ok. See referencing issue.

tim.plunkett’s picture

Status: Active » Needs review
StatusFileSize
new1.24 KB

Layout Builder checks for emptiness before rendering fields, Field UI does not. I'll leave that debate to the other issue.

I think that Markup should probably act as a computed field, which would also address this bug (by using \Drupal\Core\TypedData\ComputedItemListTrait
But in case that's not desirable, here's another approach

Status: Needs review » Needs work

The last submitted patch, 9: 3059129-markup-9.patch, failed testing. View results

scottsawyer’s picture

Patch worked well after a cache clear on markup:1.0.0-beta1 This solves a lot of headaches.

anybody’s picture

Status: Needs work » Needs review

Thank you very much @tim.plunkett! This indeed helped a lot. You're right that the static isEmpty => FALSE isn't perfect, instead it should be checked, if there is a result to return.

What do the maintainers think how to proceed here?

I'd also be OK with an RTBC here!

anybody’s picture

@tim.plunkett: Thank you very very much for the patch!

I wanted to do a real check on emptiness and I think I was successful. Created a MR based on your patch and improved it afterwards, could you have a short look?

Tested it and it seems to work fine!

anybody’s picture

anybody’s picture

grml, how I hate pushing to the wrong branch -.- sorry!

Here's the diff:
https://git.drupalcode.org/project/markup/-/merge_requests/3.diff

MR!3 is the one to review.

anybody’s picture

Title: Incompatible with layout builder » Incompatible with layout builder - no output displayed.
anybody’s picture

As this is major, I have positive internal feedback from my team and @tim.plunkett didn't have time yet to reply, I've decided to commit this and create a beta-4 release.

@tim.plunkett: Would still be nice to have your feedback, if you should have the time to have this 101% safe ;)

  • Anybody committed 63e7b0a on 8.x-1.x
    Issue #3059129 by Anybody, tim.plunkett: Incompatible with layout...
anybody’s picture

Status: Needs review » Fixed
anybody’s picture

Version: 8.x-1.0-beta1 » 8.x-1.x-dev
alexgreyhead’s picture

Just a note that the isEmpty() function on this doesn't check whether $this is an object:

  public function isEmpty() {
    $value = $this->getFieldDefinition()->getSetting('markup')['value'];
    return $value === NULL || $value === '';
  }

The simplest fix might well be just:

  public function isEmpty() {
    $value = @$this->getFieldDefinition()->getSetting('markup')['value'];
    return $value === NULL || $value === '';
  }

... or perhaps better:

  public function isEmpty() {
    if (!empty($this) && !empty($this->getFieldDefinition())) {
      $value = $this->getFieldDefinition()->getSetting('markup')['value'];
  
      return $value === NULL || $value === '';
    }
    
    // Return TRUE when $this is empty/NULL.
    return TRUE;
  }

This is the issue which tracks the bug: https://www.drupal.org/project/markup/issues/3266122

anybody’s picture

Thanks for pinging me @alexharries - I didn't see the regression issue. -.-
That was very helpful!

alexgreyhead’s picture

Very welcome, @Anybody - thank you for your time :-))

Best wishes

Alex

Status: Fixed » Closed (fixed)

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