Problem/Motivation

Found in #2948828: Layout Builder's Field Blocks do not work with Quick Edit
Use patch in #6 of that issue
To reproduce:

1. Install Layout Builder module and enable "Allow each content item to have its layout customized." on the Article content type.
2. Create an article. And to view that article (e.g node/2)
3. After that click "Layout" in the tabs to edit layout for that article
4. Remove all sections
5. Add new one column section -> add body field block into that section
6. Save Layout (you will be redirected to view page for that article)
7. Click "Quick edit" for that article

Uncaught TypeError: Drupal.quickedit.editors[editorName] is not a constructor
    at n.setupEditor (AppView.js?v=8.6.0-dev:141)
    at AppView.js?v=8.6.0-dev:44
    at Function.m.each.m.forEach (underscore.js:153)
    at n.each (backbone.js:87)
    at n.appStateChange (AppView.js?v=8.6.0-dev:43)
   ...

So each Block plugin will have its Plugin ID. Quickedit saves meta data for each field in sessionStorage. If you remove a block plugin and add the same back it will have a new plugin ID.
When you save the Layout, you will be redirected back to the canonical, and Quickedit will see that there is a new field that there is no meta data for and begin fetching it, however, since this is async, initializeEntityContextualLink() will still run and return true, and thus the contextual link will be removed from its queue (making it empty) that the fetchMissingMetadata function will try to execute once its done.

This is why the steps above fails on the first request. If you refresh that page, all metadata will be fetched and it works.

This means Quickedit assumes that you have ALL the metadata cached or none.

You can verify this by cleaning the sessionStorage, before Step 6 in the steps above, and it should work as expected.

Proposed resolution

  • Implement some API to let us purge the meta data cache
  • Or make sure that meta data items length match with the fields rendered

Remaining tasks

User interface changes

API changes

Data model changes

Comments

johndevman created an issue. See original summary.

johnwebdev’s picture

Issue summary: View changes
tedbow’s picture

Issue summary: View changes

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

wim leers’s picture

Title: Quickedit assumes that all fields meta data are stored in cache or none » Quick Edit assumes that all fields meta data are stored in cache or none
Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

Quickedit assumes that all fields meta data are stored in cache or none

I just:
first loaded /node/1 (an article node with tags)
then manually deleted the Drupal.quickedit.metadata.node/1/title/en/full and Drupal.quickedit.metadata.node/1/field_tags/en/full
enabled JS debugger
then loaded /node/1 again, and observed it fetching the now-missing metadata prior to initializing Quick Edit for that entity

Which is also why the code looks like this:

      fetchMissingMetadata(function (fieldElementsWithFreshMetadata) {
        _.each(fieldElementsWithFreshMetadata, processField);

        contextualLinksQueue = _.filter(contextualLinksQueue, function (contextualLink) {
          return !initializeEntityContextualLink(contextualLink);
        });
      });

Now how the initializing of the Quick Edit contextual link for an entity happens in a callback called by fetchMissingMetadata() after it fetched the missing metadata :)

wim leers’s picture

Quickedit will see that there is a new field that there is no meta data for and begin fetching it, however, since this is async,

This is not async.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

pameeela’s picture

@johnwebdev do you think this is still an issue? If so would you be able to provide steps to reproduce?

johnwebdev’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

No, I can't reproduce it anymore. Closing :) Thanks!

pameeela’s picture

Issue tags: +Bug Smash Initiative

Great, thanks!