Problem/Motivation
As a site builder / front end developer, I would like to be able to distinguish layouts displayed on the edit UI from layouts rendered normally.
This would be especially useful if a layout does not display empty regions: if it does so, then on the edit U, it makes impossible to place any components in the corresponding region.
Core change record: https://www.drupal.org/node/3273879
Proposed resolution
Utilize layout preview mode: use PreviewAwarePluginInterface::setInPreview() to mark layouts as being in preview on Layout Paragraphs edit UI.
User interface changes
Nothing.
API changes
Layouts rendered in Layout Paragraphs edit UI are marked as "being in preview", just like on Layout Builder UI, so the in_preview/code> twig variable could be used in layout templates to distinguish preview / non-preview states.
Data model changes
Nothing.
| Comment | File | Size | Author |
|---|---|---|---|
| #30 | 3392735-inpreview.patch | 824 bytes | minoroffense |
| #12 | layout_paragraphs-3392735-MR139-12.patch | 3.78 KB | anybody |
Issue fork layout_paragraphs-3392735
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
Comment #3
huzookaSeems that Gitlab CI is out of office hours...
Comment #4
huzookaComment #5
huzookaAttaching fix-only patch.
Comment #6
hudri@huzooka:
Could this setting be used to determine the
_admin_routecontext from routes?Currently, when LP performs Ajax callbacks, we don't know if we are in admin mode or not. Could this Plugin be used to solve issues 3350168 (which currently is stuck, because it is a node-only solution).
Comment #7
gregory_visibleThis issue is quite old , but not setting preview mode also prevent layouts generated from SDC by Ui_patterns to work correctly.
See : https://www.drupal.org/project/ui_patterns/issues/3578831
Comment #8
anybodyThank you all!
Based on #7 I think we should then rate this as bug. And I think it should be checked, if the same issue exists in 3.x so it can be fixed in both branches?
Comment #9
anybodyComment #10
anybodyRelabelled based on #7. The same issue exists in 3.0.x.
@huzooka could you maybe add the same fix for 3.0.x-dev and check why tests fail?
Comment #11
anybodyThis became a major issue for us now, because the preview plus view mode not being passed correctly leads to an infinite loop of rendering indirectly. The MR!139 fixes it, thank you @huzooka!
PS: I think the existing MR should target 2.1.x-dev?
Comment #12
anybodyStatic patch attached until this is merged.
This works perfectly well with 2.1.x-dev and 3.0.x-dev and also the stable versions!
So I'm setting this RTBC, still we should prepare the MRs to help the maintainers.
Comment #16
grevil commentedCreated two seperate branches for 2.1.x and 3.0.x.
Comment #21
grevil commentedFailing tests look unrelated. Cypress seems to have issues.
Comment #22
anybodyStill a major issue for us.
Comment #23
alorencThe 3.0.x branch no longer uses PHPUnit Functional or FunctionalJavascript tests; browser testing is now done with Cypress (see tests/cypress).
Please migrate the changes in tests/src/FunctionalJavascript/PreprocessLayoutTest.php to a Cypress test for 3.0.x.
Comment #24
alorencComment #25
grevil commentedComment #26
grevil commentedMigrated the test into a cypress test!
Comment #27
anybodyAll green, thank you @grevil
Comment #28
alorencThat was fast, thanks!
Comment #30
minoroffense commentedHere's a patch with just the code for 2.1.x
Comment #31
anybodyThank you @minoroffense - would be great to have this merged in both versions. :)
Comment #35
justin2pin commentedMerged and marked as fixed. I added a check to make sure the
LayoutInstancealso implementsPreviewAwarePluginInterfacebefore callsetInPreview(), since that isn't a requirement for all layout plugins. Also moved test coverage to unit tests. Thanks for the work on this!Comment #37
anybodyWhao, thank you very very much once again @justin2pin! Nice to see this fixed finally!