#159 | 2948828-159.patch | 30.11 KB | tedbow |
|
#159 | interdiff-156-159.txt | 990 bytes | tedbow |
#158 | Screen Shot 2019-03-25 at 11.06.42 AM.png | 173.21 KB | webchick |
#156 | 2948828-quickedit-156.patch | 29.57 KB | Wim Leers |
|
#156 | interdiff.txt | 1.04 KB | Wim Leers |
#145 | 2948828-quickedit-145.patch | 29.48 KB | tedbow |
|
#145 | interdiff-131-145.txt | 8.5 KB | tedbow |
#145 | 2948828-quickedit-145-x50.patch | 31.39 KB | tedbow |
|
#145 | core-quickedit-x100.patch | 1.91 KB | tedbow |
|
#143 | 2948828-142.patch | 38.89 KB | tedbow |
|
#143 | interdiff-137-142.txt | 1.8 KB | tedbow |
#141 | 2948828-quickedit-140-50x.patch | 34.23 KB | Wim Leers |
|
#141 | interdiff-136-140.txt | 533 bytes | Wim Leers |
#137 | 2948828-137.patch | 38.76 KB | tedbow |
|
#137 | interdiff-135-137.txt | 9.16 KB | tedbow |
#136 | 2948828-quickedit-136-50x.patch | 34.21 KB | Wim Leers |
|
#136 | interdiff.txt | 3.61 KB | Wim Leers |
#135 | 2948828-quickedit-135.patch | 32.19 KB | Wim Leers |
|
#135 | interdiff.txt | 2.61 KB | Wim Leers |
#131 | 2948828-quickedit-131.patch | 32.48 KB | Wim Leers |
|
#131 | interdiff.txt | 5.77 KB | Wim Leers |
#130 | 2948828-quickedit-130.patch | 38.04 KB | Wim Leers |
|
#130 | interdiff.txt | 14.46 KB | Wim Leers |
#124 | 2948828-quickedit-124.patch | 35.49 KB | Wim Leers |
|
#124 | interdiff.txt | 3.39 KB | Wim Leers |
#122 | 2948828-quickedit-121-interdiff.txt | 1.26 KB | tim.plunkett |
#122 | 2948828-quickedit-121.patch | 35.56 KB | tim.plunkett |
|
#117 | 2948828-116.patch | 35.43 KB | Wim Leers |
|
#117 | interdiff.txt | 1.32 KB | Wim Leers |
#115 | 2948828-114.patch | 35.17 KB | Wim Leers |
|
#114 | interdiff.txt | 13.56 KB | Wim Leers |
#110 | 2948828-110.patch | 36.38 KB | tedbow |
|
#110 | interdiff-107-110.txt | 1.16 KB | tedbow |
#107 | 2948828-107.patch | 36.36 KB | tedbow |
|
#107 | interdiff-103-107.txt | 1.62 KB | tedbow |
#103 | 2948828-quickedit-102-interdiff.txt | 6.56 KB | tim.plunkett |
#103 | 2948828-quickedit-102-PASS.patch | 36.35 KB | tim.plunkett |
|
#103 | 2948828-quickedit-102-FAIL.patch | 35.53 KB | tim.plunkett |
|
#101 | 2948828-quickedit-101.patch | 33.99 KB | tedbow |
|
#101 | interdiff-99-101.txt | 981 bytes | tedbow |
#99 | 2948828-quickedit-99-interdiff.txt | 18.95 KB | tim.plunkett |
#99 | 2948828-quickedit-99.patch | 33.94 KB | tim.plunkett |
|
#97 | 2948828-quickedit-97-interdiff.txt | 20.74 KB | tim.plunkett |
#97 | 2948828-quickedit-97.patch | 32.72 KB | tim.plunkett |
|
#92 | 2948828-92.patch | 36.86 KB | tedbow |
|
#92 | interdiff-87-92.txt | 26.55 KB | tedbow |
#89 | 2948828-87.patch | 36.58 KB | tedbow |
|
#89 | interdiff-82-87.txt | 10.76 KB | tedbow |
#83 | 2948828-82-test-only-fail.patch | 19.37 KB | tedbow |
|
#82 | 2948828-82.patch | 35.54 KB | tedbow |
|
#82 | interdiff-79-82.txt | 12.19 KB | tedbow |
#79 | 2948828-79.patch | 36.99 KB | tedbow |
|
#79 | interdiff-72-79.txt | 9.65 KB | tedbow |
#76 | 2948828-76-x50.patch | 45.55 KB | tedbow |
|
#72 | 2948828-72.patch | 43.59 KB | tedbow |
|
#72 | 2948828-72.patch | 43.59 KB | tedbow |
|
#72 | interdiff-71-72.txt | 1.52 KB | tedbow |
#71 | interdiff-69-71.txt | 698 bytes | tedbow |
#71 | 2948828-71.patch | 43.49 KB | tedbow |
|
#69 | 2948828-quickedit-68-interdiff.txt | 2.21 KB | tim.plunkett |
#69 | 2948828-quickedit-68.patch | 43.52 KB | tim.plunkett |
|
#67 | 2948828-quickedit-67-interdiff.txt | 2.65 KB | tim.plunkett |
#67 | 2948828-quickedit-67.patch | 43.96 KB | tim.plunkett |
|
#64 | 2948828-64.patch | 44.61 KB | tedbow |
|
#64 | interdiff-63-64.txt | 1.45 KB | tedbow |
#63 | 2948828-63-will-fail.patch | 43.95 KB | tedbow |
|
#63 | interdiff-59-63.txt | 4.31 KB | tedbow |
#59 | 2948828-59.patch | 42.48 KB | tedbow |
|
#59 | interdiff-55-59.txt | 17.26 KB | tedbow |
#55 | 2948828-55.patch | 28.39 KB | tedbow |
|
#55 | interdiff-53-55.txt | 8.07 KB | tedbow |
#53 | 2948828-53-plus-3026434-66.patch | 55.37 KB | tedbow |
|
#53 | 2948828-53-do-not-test.patch | 25.2 KB | tedbow |
|
#53 | interdiff-50-53.txt | 4.29 KB | tedbow |
#50 | quick_edit_test_fail_on_tags.png | 49.21 KB | tedbow |
#50 | 2948828-50.patch | 39.74 KB | tedbow |
|
#50 | interdiff-47-50.patch | 11.58 KB | tedbow |
|
#47 | 2948828-47-plus-3026434-59.patch | 41.59 KB | tedbow |
|
#47 | interdiff-42-47-no-3026434-59.txt | 9.5 KB | tedbow |
#47 | 2948828-47-do-not-test.patch | 26.53 KB | tedbow |
|
#43 | 2948828-42.patch | 21.22 KB | tedbow |
|
#43 | interdiff-40-42.txt | 7.07 KB | tedbow |
#40 | 2948828-40.patch | 19.13 KB | tedbow |
|
#40 | interdiff-39-40.txt | 3.35 KB | tedbow |
#39 | 2948828-39.patch | 18.46 KB | tedbow |
|
#39 | interdiff-37-39.txt | 2.5 KB | tedbow |
#37 | 2948828-37.patch | 17.75 KB | tedbow |
|
#35 | 2948828-35.patch | 19.01 KB | tedbow |
|
#33 | interdiff-31-33.txt | 3.11 KB | tedbow |
#33 | 2948828-33.patch | 19 KB | tedbow |
|
#32 | Screen Shot 2019-01-18 at 11.14.18 PM.png | 223.65 KB | Kristen Pol |
#32 | Screen Shot 2019-01-18 at 11.13.20 PM.png | 207.52 KB | Kristen Pol |
#31 | 2948828-31.patch | 15.9 KB | tedbow |
|
#31 | interdiff-30-31.txt | 13.25 KB | tedbow |
#30 | 2948828-30.patch | 12.57 KB | tedbow |
|
#30 | interdiff-29-30.txt | 16.53 KB | tedbow |
#28 | 2948828-28.patch | 14.9 KB | tedbow |
|
#28 | interdiff-25-28.txt | 3.8 KB | tedbow |
#25 | 2948828-25.patch | 15.78 KB | tedbow |
|
#25 | interdiff-21reroll-25.patch | 4.27 KB | tedbow |
|
#21 | 2948828-21-reroll-18.patch | 15.75 KB | tedbow |
|
#19 | interdiff-18-19.txt | 2.72 KB | tedbow |
#19 | 2948828-19-why-no-fail.patch | 17.97 KB | tedbow |
|
#18 | 2948828-18.patch | 15.91 KB | tedbow |
|
#14 | 2948828-14.patch | 10.1 KB | tedbow |
|
#14 | interdiff-10-14.txt | 4.4 KB | tedbow |
#10 | interdiff_6-10.txt | 1.46 KB | johnwebdev |
#10 | 2948828-10.patch | 9.96 KB | johnwebdev |
|
#6 | interdiff-2948828-4-6.txt | 1.83 KB | samuel.mortenson |
#6 | 2948828-6.patch | 9.76 KB | samuel.mortenson |
|
#4 | interdiff-2948828-2-4.txt | 4.18 KB | samuel.mortenson |
#4 | 2948828-4.patch | 9.78 KB | samuel.mortenson |
|
#2 | 2948828-2.patch | 9.19 KB | samuel.mortenson |
|
Comments
Comment #2
samuel.mortensonThis patch adds a custom view mode to fields output by Layout Builder, which informs Quick Edit that Layout Builder implements
hook_quickedit_render_field()
, a hook that lets modules re-render fields edited with Quick Edit. The custom view mode is in the format layout_builder-(section delta)-(component UUID). With that informationlayout_builder_quickedit_render_field()
can load the Layout view display object and re-render the (field block) component that has been edited.I also exposed
getRuntimeSections
as a public method for\Drupal\layout_builder\Entity\LayoutEntityDisplayInterface
- it's surprisingly hard to get the sections for a given entity and view mode ID without that method!Comment #4
samuel.mortensonThis should fix tests - simulating a click feels weird but there's a lot of history to this problem. See https://github.com/jcalderonzumba/gastonjs/issues/19 and #2773791: Clicking elements with children in Javascript tests throws a GastonJS exception
Comment #5
Wim LeersLooks great!
Yay, this (weird!) API comes to the rescue again :)
The first array part is the module name. That's why it can be omitted when destructuring.
API change!
Nit: no need for
$editor
, just doEditor::create([…])->save()
?Supernit: I think it's better to use something other than
'full_html'
. Evensome_format
is better IMHO.I don't think this permission is necessary?
Nit: s/UUID/component UUID/
😱
Hm, this check is not very strict. It could theoretically still allow the text to be rendered but the surrounding markup to be lost, couldn't it?
Comment #6
samuel.mortensonAddressed all of #5.
#5.3 - I added the API change to the IS, I need @tim.plunkett to review this before RTBC.
Comment #7
johnwebdev CreditAttribution: johnwebdev commentedI did some manual testing with and without Layout Builder using this patch and the behaviours are the same. Nice work!
Comment #8
mtodor CreditAttribution: mtodor at Thunder commentedNice work. I have tested this a bit and it looks good. I have also played a bit around with it and encountered few issues.
I have tested everything on default Drupal article.
Case 1:
I used following display layout: two one column sections. The top section contains only body field block and the section below is a default layout for the article (what we get after enabling layout builder).
When I use quick edit on any of two body fields, I get following error:
Changes are saved.
Edited body field block is re-rendered, but another body field block is not.
=> When I have single body field block in layout, it works properly. So I guess it's some issue with multiple uses of same field block in one layout.
Case 2:
It looks like, that quick edit works only for single column sections. If I have two column (or some other), then the Quick edit boxes are not enabled for field blocks inside it.
Case 3:
It's a bit edge case and tricky to reproduce. If I have enabled "Allow each content item to have its layout customized.", it's possible to reproduce this problem in following steps.
I'm not sure what is the problem. Looks like some temp store or some caching. Since it works after reload of the page. :(
Comment #9
tim.plunkettGood feedback @mtodor!
Removing from sprint tag since @samuel.mortenson isn't actively working on this. Please feel free to retag if someone picks this up!
Comment #10
johnwebdev CreditAttribution: johnwebdev commented#8.1 Not sure whet ever this would work if you have a duplicated field rendered without using Layout Builder? If that's true, perhaps that could be a follow-up?
#8.2 This patch addresses this issue.
#8.3 I've created a new issue for this: https://www.drupal.org/project/drupal/issues/2966136
Comment #11
tedbowSetting "Needs Review" for tests
Comment #12
phenaproximaLooks good to me!
I'm not sure we need this check; I don't think Quick Edit works with config entities at all, and I can't imagine that this hook would even be invoked for any situation except rendering fields on a content entity. So the very fact that we're implementing a Quick Edit hook implies that $entity is fieldable.
We should add a @todo to use EntityContext when #2932462: Add EntityContextDefinition for the 80% use case is fixed.
This line seems a little fragile, and I can't quite articulate the reasons why. Is there some other way we could do this? Could we get in front of Quick Edit's relevant theme/preprocess functions, or wrap around them? I dunno. Maybe we should open a follow-up to revisit this?
It'd be nice to expand this doc comment to explain what, exactly, a "runtime section" is.
Should be protected.
These lines can be collapsed into one:
$component_uuid = key(reset($sections)->getComponents());
Can the comment be expanded to explain why 403s would happen if we *didn't* reset the request state?
Comment #13
tim.plunkettNW for #12
Comment #14
tedbowre #12
1. I think we should leave the check in. I am not sure in which ways you can extend QuickEdit also
hook_quickedit_render_field
could have been made with it's first argument asFieldableEntityInterface
but it was made withEntityInterface
as the first argument so we should assume it could actually be called with just that. And out next line has a call toEntityViewDisplay::collectRenderDisplay()
which expects aFieldableEntityInterface
which would throw an exception if it didn't get one.2. added @todo
3. I have changed to only take effect if
$component['#base_plugin_id'] === 'field_block'
. Since we really only care about this plugin.4. Expanded to my understanding.
5. Looking at other tests this is always public.
6. Fixed
7. I removed this and the tested passed locally. Lets see if it does on DrupalCI.
I also change the test to extend WebDriverTestBase
Comment #16
victor-shelepen CreditAttribution: victor-shelepen as a volunteer commentedThe tag has been added to make the issue visible on the Kanban sprint board.
Comment #17
tim.plunkettComment #18
tedbowNeed re-roll
Is actually being called? I am going to upload a patch without this running and the tests still pass.
Since this patch another commit add
layout_builder_entity_view_alter
So to separate the logic of the 2 purposes for this hook now I have created
_layout_builder_quick_edit_view_alter()
.The existing logic for extra fields have moved in the new static method
\Drupal\layout_builder\Plugin\Block\ExtraFieldBlock::entityViewAlter()
we were already calling a static method which I changed to private static method.This only worked because
body
was the first field. Now that extra fields are working this is not true.Adding waits before clicking these elements because I was getting fails locally
Also checking if exists after waits.
Comment #19
tedbowComment #21
tedbowRerolling #18
Comment #22
tedbowIs there a way around this? Or does this just make sense?
Comment #23
tim.plunkettThis should work:
If it doesn't, that's due to a bug in OverridesSectionStorage that we're wrestling with currently in #2976148: Layout-based entity rendering should delegate to the correct section storage instead of hardcoding to either defaults or overrides.
Comment #24
tim.plunkettOpened #3020677: Even when empty, Overrides returned instead of Defaults when using SectionStorageManagerInterface::findByContext() specifically to address this
Comment #25
tedbowHere is reroll and a fix using #23(slightly updated)
Comment #28
tedbow#25 failed because before the reroll on move all of
layout_builder_entity_view_alter
into\Drupal\layout_builder\Plugin\Block\ExtraFieldBlock::entityViewAlter()
to separate it out.but since #3007973: Layout builder prevents the rendering of extra fields (like Links) on pages not using Layout Builder changed
layout_builder_entity_view_alter
so it needed to be updated.Comment #29
tim.plunkettThis makes sense and is a good refactor, but I don't see this as being in scope
this is very confusing, and I think incorrect?
shouldn't it end with
as $delta
since the switch to Element::children, and then the next line makes more sense.I mean, I'm all for it. Wish we'd done it the first time. But this was in 8.6.0, so idk that we can break it :(
is this a todo to be resolved before commit? if not, needs an issue
I feel like this is copied from somewhere, maybe deserves a helper?
extraneous ;
Comment #30
tedbow@tim.plunkett thanks for the review.
layout_builder_entity_view_alter
use to be only this logic and now it is two separate things. But I agree this is out of scope.So instead I made new
QuickEditIntegration
class that will have 2 methods for the 2 hooks that need logic for quick edit. I think this is cleaner.[0=>0, 1=> 1]
Also because I can see the chrome browser for the javascript test I can see that quick is actually getting an error but the test is still passing. Something is wrong with the test.
To confirm this this patch throws an exception in
\Drupal\layout_builder\QuickEditIntegration::quickEditRenderField()
and I think the test will still pass.I think we should actually extend
\Drupal\Tests\quickedit\FunctionalJavascript\QuickEditJavascriptTestBase
because there are a lot of helper methods in there. But don't have time right now.I debug a little and the problem is in
\Drupal\quickedit\QuickEditController::entitySave
$tempstore->get($entity->uuid())
returns a NULL for some reason. I have test manually though and I can get quick edit to work with this patch. So I think it is a testing issue and hopefully using QuickEditJavascriptTestBase will allow us to fix this.Comment #31
tedbowHere I have make
\Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderQuickEditTest
extend\Drupal\Tests\quickedit\FunctionalJavascript\QuickEditIntegrationTest
This makes sure that the test coverage for nodes and custom blocks that QuickEdit module provides will also pass when the displays are using the Layout builder. This required 2 small changes to in QuickEdit test code.
QuickEditJavascriptTestBase::getQuickEditFieldId()
because the attribute used for Quick edit fields depends on the view_mode which is different using Layout Builder.testCustomBlock()
and into the setup.Comment #32
Kristen PolThanks for the patch. I tested #31 and it's not working for me so maybe I'm doing something wrong. Here's what I did:
Putting back to "Needs work" based on this.
Quick edit only works for title (with layout):
Quick edit only works for title and body (without layout):
Comment #33
tedbow@Kristen Pol thanks for testing the screenshots. I think the problem wasn't that you have override vs defaults. I think if you added same fields to the default it would have the same bug.
The problem I think stems from
\Drupal\quickedit\MetadataGenerator::generateFieldMetadata()
This gets an error because
->getRenderer($field_name)
will return a null because\Drupal\Core\Entity\Entity\EntityViewDisplay::getRenderer
hasBut if we look at
This still just getting looking at
content
which is not Layout builder specific.So if you field was not being displayed before you turned on Layout Builder then it will not be returned. Also some fields were not displayable at all without layout Builder.
In the quick edit case because of the other changes in the patch that create a unique view mode with both the section delta and the component uuid we can actually figure out the component field settings.
I am not sure what to do in other cases and not sure why this doesn't cause other problems. We could always figure out the field formatter settings for the field block if the field is display but then also the field could be displayed twice.
Only testing layout_builder in this patch.
Comment #35
tedbowchange to drupalci.yml
Comment #37
tedbowremoved drupalci changes
Comment #39
tedbowThe fail in
\Drupal\Tests\config\Functional\ConfigImportAllTest::testInstallUninstall()
does seem related.Changing to use
parent::getFieldDefinitions()
unless the display is for quickedit.Comment #40
tedbowWe should only be calling
getQuickEditFormatterSettings()
if$this->isLayoutBuilderEnabled()
And then if we can't tell the component via quickedit we should just loop through all sections and components and find the field block. Otherwise will be getting the settings from
$this->contents()
which should only be backup if the field is not in a component.we should base this logic on
$this->isLayoutBuilderEnabled()
alsoComment #42
tedbowSome refactoring and adding testing of a layout override using quickedit.
Comment #43
tedbow.... and the patch
Comment #45
bnjmnmI figured out what is causing the test failure in
\Drupal\Tests\config\Functional\ConfigImportAllTest::testInstallUninstall()
. I'll provide a patch tomorrow with that fix+ the additional tests requested in the Todo. Mentioning it now on the off chance someone was planning to tackle this in the next 12 hrs.Comment #46
Kristen PolSince this needs work, here are a few more things that could be updated at the same time. Thanks.
Nitpick: Extra empty line.
Nitpick: Extra space before pipe.
Missing doc block.
"module name-id" isn't clear to me. Is it supposed to mean:
[module-name]-[id]?
Typos: publised and dispaly. And, needs an Oxford comma.
Needs doc block.
Nitpick: Extra empty space.
Comment #47
tedbowok I have done some work on this that I meant to post earlier.
@Kristen Pol thanks for review but I haven't had time to address it yet. I will though
I changed this to also pass the entity_id and revision_id(if any) because I am not sure how else we are going to get the information about overrides which is stored as a field value.
@@ -0,0 +1,158 @@
+ if (isset($component['content']) && isset($component['#base_plugin_id']) && $component['#base_plugin_id'] === 'field_block') {
Made new private method here
\Drupal\layout_builder\QuickEditIntegration::supportQuickEditOnComponent()
that determines if we should support a component.The extra check I added in the method was not allow quickedit on non-view configurable fields.
\Drupal\Tests\config\Functional\ConfigImportAllTest::testInstallUninstall()
fail.Which was a change to
layout_builder_install to check <code>!empty($field_layout['settings'])
This came from @bnjmnm. If remember correctly this is what he was talking in #45
Other things remaining
Comment #49
Wim LeersLet me start with: great progress here, and nice job overall! Now let's figure out the remaining tricky bits :) 💪
Thanks for thinking about that! 🙂 🙏
It's been years since I last looked at this, so I had to dig in to the code to answer this too. Remarks:
sessionStorage
, notlocalStorage
. So: the mere act of closing a tab actually already clears this cache, and the cache is per-tab.sessionStorage
is used (persistent for the life of a browser tab) instead oflocalStorage
(persistent across browser tabs, browser windows and sometimes even browser sessions).data-quickedit-field-id
attribute in the HTML change when the layout changes, since that would cause a cache miss. If this is not the case, I'm happy to look into how Quick Edit can accommodate this.#47.2: I think this makes perfect sense. I'd love to see test coverage for this: 1) Quick Edit triggered without Layout Builder enabled for a node type, 2) enable it for a node type, verify that Quick Edit still works, 3) override the layout in a forward revision and verify that once again Quick Edit works. I think that would cover all edge cases, and would also prove that the aforementioned client-side caching isn't getting in the way.
Patch review below. Some things weren't clear to me, a comment (and perhaps patch) addressing some of my questions would allow me to review some of the deeper bits that I couldn't get to due to the things that I didn't understand.
I think this should adopt the pattern used by
content_moderation.module
, where an actual service is retrieved.Übernit: in
.module
files we don't use camelCase.This is not just a set of helper methods anymore, because it relies on services getting injected. Let's turn this into a proper service? (Also see point 1.)
I've done this too, but …
RevisionableInterface
is a lie.All content entities implement
\Drupal\Core\Entity\ContentEntityInterface
, and that implementsRevisionableInterface
. You either need to$entity->getEntityType()->isRevisionable()
, or, in this case, you could get away with!$entity->isDefaultRevision()
.I doubt this works correctly, because it's a still a "Quick Edit view mode ID", not a "Entity API view mode ID".
(Yes, this API is frustratingly weird, I apologize.)
Another 🐫 spotted 🕵️♂️
🔍🐛 Some weird indentation here, surprisingly it doesn't trigger PHPCS.
s/should be/are/
s/field_blocks/field_block/
s/QuickEdit/Quick Edit/
Could use an
@see \Drupal\layout_builder\Plugin\Block\FieldBlock
.Nit: this is the only place it's used, it's IMHO unnecessarily confusing to alias it to a local variable.
This is a "todo of intent", should be completed still, but sounds good!
, , $view_mode
, this is confusing. What's the rationale? Can we centralize the logic?The fourth parameter is not documented.
Why are we special-casing these three fields?
I don't understand what this is doing. The comment mentions
body
, but the code does not. And why is it okay to hardcode entity and revision ID?Why do we need to install
standard
? I suspect this is just a temporary thing, to make it easier to get the tests to a passing, complete state? I think that'd be a great strategy, but we should have a@todo
to remove this prior to commit.Comment #50
tedbow@Wim Leers Thanks for the review!
Re test coverage that sounds like good idea!
or actually use a service like content_moderation.module does in a couple cases
Drupal::service('content_moderation.moderation_information')
.since #2949965: \Drupal::classResolver() could be more helpful was done in the last year I thought that is what I should be using.(which does use the service internally.
Fixing the camel case.
ContainerInjectionInterface
Especially since
\Drupal\Core\DependencyInjection\ClassResolver::getInstanceFromDefinition
explicitly handles this interface. Is not use a service a further message that this class is not for reuses(+ it being @internal)?this is similar to
\Drupal\content_moderation\EntityTypeInfo
which also is retrieved via classResolver and injects services from the container.$entity->getEntityType()->isRevisionable()
. Not sure how!$entity->isDefaultRevision()
would work. Couldn't you be editing the default revision?Do we need to add another context 'quick_edit_view_mode'? Technically I think you could find the correct entity view mode from this info because you have the uuid id of the component which should be unique if we did allow overrides of other view modes.
No worries about the API weirdness, it happens.
added comment
// Save the current user to re-login after Layout Builder changes.
added this in the other case in the file where this is happening.
\Drupal\layout_builder\QuickEditIntegration::supportQuickEditOnComponent()
is excluding these fields I don't think we need the todo. Removed.The title field when displayed outside of the layout will still be tested because we are extending
\Drupal\Tests\quickedit\FunctionalJavascript\QuickEditIntegrationTest
I don't think there is anything we can centralize here.
replaceLayoutBuilderFieldIdKeys()
is already called by bothassertEntityInstanceFieldStates()
andreplaceLayoutBuilderFieldIdKeys()
Fixed the comment
The test are still failing
Here is screen from when the test fail
at
it seems like placeholder it is not being removed and there is an ajax response.selector that is not valid.
Investigating
Comment #53
tedbowI think part of the problem is using the ":" instead of "-" and that not working with QuickEdit js.
Change this fixes the test for me. I did this because the UUID has dashes in it so we couldn't add entity id after this. So just changing the UUID to use "_" in the view_mode string which will then be changed back on extraction.
will include a do not test patch this time. also the interdiff doesn't include changes in #3026434
Comment #55
tedbowI realized from @Wim Leers' comments that we can't actually put the revision id in the view_mode. Because the field info is cached for the entity and doesn't take into account revisions.
I manually test this and quick edit doesn't work on the same node again after you save it.
So I removed this we can still load the correct revision because QuickEdit doesn't support pending revisions.
#2903524: Don't add quickedit to displays where entities have a forward revision.
\Drupal\Tests\quickedit\FunctionalJavascript\QuickEditIntegrationTest
. I am not sure if we should just be copying this test but it seems good they are extending it so are sure what ever is tested with quickedit is test with Layout Builder and quickedit.This sadly will not work at least from step 1 to step 2 right now. My understand the field information which contains the (quickedit)view_mode will be cached on the client so when you enable layout builder it will not trigger the client cache to be cleared.
I am not exactly sure yet how to fix this. I know quickedit uses metadata but I am sure if this is used vary the client cache like it is Context Link client storage.
In the Contextual module you add information to the contextual metadata it will keep a separate version of the links.
Is something like this possible with Quickedit?
Comment #56
tedbowLooking at
quickedit_entity_view_alter()
it sets
$build['#attributes']['data-quickedit-entity-id'] = $entity->getEntityTypeId() . '/' . $entity->id();
I am wondering if we were to use our own
hook_entity_view_alter
to change this when layout builder is enable for a bundle would that allow clearing the fields on the client storage.On caveat to that is we would have to get
layout_builder_entity_view_alter
to run afterquickedit_entity_view_alter
to alter it.We are actually already implementing
layout_builder_module_implements_alter
to make our implementation runs last. But I don't think is actually having any effect.I could be wrong but .....
This comes from
\Drupal\Core\Entity\EntityViewBuilder::buildMultiple()
:where $view_hook in "[ENTITY_TYPE}_view".
Reading through the docs for
hook_module_implements_alter
So actually changing the order of 'entity_view_alter' actually has no effect.
Comment #58
Wim LeersThis reminds me of #2910005: JavaScript errors thrown when viewing non-latest default revision of entity — indeed, Quick Edit doesn't support this at all! And for good reason. Thanks for also linking #2903524: Don't add quickedit to displays where entities have a forward revision..
Will review #50–#57 next, but @tedbow just told me he found a solution, so waiting for that to land first :)
Comment #59
tedbowI will attach the patch now and then do a self-review to explain the fix.
Comment #60
tedbowHere we attach a hash of the current sections for any entity that is rendered by this module.
This will be used in Javascript to compare it to the previous section hash if any and remove any metadata for the entity that quickedit has stored on the client if the hash is not the same or isn't present.
We attach our new
drupal.layout_builder_quickedit
. The previous JS library is only need on the admin site where as this will be needed when the entities are being viewed.We only do any of this if the user has access to quickedit.
Here will loop through any section hashes that where set on the server.
If section hash for this entity/view_mode either does not exist or is different that than the previous one stored we delete any metadata for this particular entity that quickedit has stored.
This will force quick edit to refetch info whenever layout builder is enabled for an entity(the hash wasn't there at all) or the sections have been somehow changed(the hash is different).
UPDATE: I just realized that this logic will only run when layout builder has rendered the entity so it does not cover the case where layout builder was enabled previously for an entity but then has disabled.
To solve this in
\Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay::buildSections()
when
$storage = $this->sectionStorageManager()->findByContext($contexts, $cacheability);
is empty we probably need to set a JS var that there is not hash so we can still clear metadata. This should still only clear the metadata once when the layout builder is disabled not everytime after this.
Will add this logic and test coverage.
Here is the new test coverage that uses quickedit on the same article in this order
We need to add another case at the end where layout builder is again disabled for the bundle( we will have to revert the override first)
I commented out this line because of the bug here #2914826: Drupal.quickedit.metadata stores entity label in window.sessionStorage, does not update after entity label changed. The current quick edit test coverage does not hit this because it does NOT edit the same entity again after the updating the label.
Until we fix this we might need some kind of flag to skip this known bug on subsequent edits of the same entity.
I have updated QuickEdit's own test again to have run the same test case on the entity after it is update once.
If I hadn't commented the line related to #2914826: Drupal.quickedit.metadata stores entity label in window.sessionStorage, does not update after entity label changed this would fail also.
The quickedit tests expect contextual "Edit" mode not be to enabled when the test starts off so I made this method to reset it so we can test the same entity multiple times.
I kept the previous test coverage in a temporary old file because I want to look at again and make sure we are still covering everything we were before the tests were refactored. At that point I will delete this from the patch.
Comment #61
tedbowAdding related issue #2914826: Drupal.quickedit.metadata stores entity label in window.sessionStorage, does not update after entity label changed.
This issue was already related #2966136: Quick Edit assumes that all fields meta data are stored in cache or none but may be solved at least for Layout builder by this patch.
In that issue @johndevman mentions as possible solutions
I think 1) here would make this patch not have to assume how quickedit stores metadata on the client.
For instance if we had a new Javascript method
Drupal.quickEdit.clearCacheForEntity(entity_type, entity_id);
Then the Javascript in this patch could be simplified.
Comment #63
tedbowComment #64
tedbowfix for test coverage in #63
Comment #67
tim.plunkettHaving trouble debugging the one failure, but reverting the change to layout_builder_install for now to fix the other test.
Comment #69
tim.plunkettPosting a bit more work here, but not making much progress on the QE bugs. mostly focused on the other fails.
Comment #71
tedbow@tim.plunkett thanks for the fixes for the other tests.
This should fix LayoutBuilderQuickEditTestOld.
Comment #72
tedbowAdding layout_builder_test_css_transitions module to tests. Because they are passing locally for me. This may fix it.
Comment #76
tedbowI think #72 is error to do with timing. This passes on my local.
Trying a 50x test see if it randomly passes on Drpualci. If so I will try to figure out what the timing issue is.
Comment #78
tedbowI have banging my head against this I don't think we can extend
\Drupal\Tests\quickedit\FunctionalJavascript\QuickEditIntegrationTest()
That test only edits the same node once. I have tried to alter it to see if it can handle editing the same node twice without layout builder involved and it fails randomly. see #3037436: [random test failure] Make QuickEditIntegrationTest more robust and fail proof
I am not sure why but the test doesn't fail all the time.
Is there a simpler way to test this?
Comment #79
tedbowThis patch gets rid of this class bring the test method into the new class.
I still think this the more comprehensive test will fail on DrupalCI because it attempts to edit the same node more than once
Comment #80
tedbowI talked with @xjm and @tim.plunkett about the random test failures in Quick Edit re #3037436: [random test failure] Make QuickEditIntegrationTest more robust and fail proof
We agreed that good test coverage for Layout Builder/quickedit integration until this gets would be"
This test because of random failures will not work on completely but we should able to confirm that quick edit at least initializes correctly.
Comment #82
tedbowTest coverage as described by #80
Comment #83
tedbowHere is test-only version to prove it doesn't work with fix.
Comment #84
tedbowComment #86
tedbow#85 was an expected test only fail.
Comment #87
tim.plunkettTests look good enough considering, thanks for the followup!
This should be able to live in
layout_builder_entity_view_alter()
Possibly this too? Not sure, but ideally
Extra space
Is there somewhere this can point to?
Missing ()
This whole method could use some inline comments
I think this should check the base plugin ID instead
Missing docblock, also the rest should have inline comments
Alters the entity view build? or something? It doesn't alter the entity
That was committed, this can switch
Comment #89
tedbow@tim.plunkett thanks for the review!
\Drupal\layout_builder\QuickEditIntegration::entityViewAlter()
$plugin->getBaseId() === 'field_block'
.$plugin->getBaseId() === 'field_block'
instead for plugin class.Realized I should checking the QuickEdit permission here because altering is not needed if the current user doesn't have the permission. Removes the need for the check later I mentioned above.
Comment #90
Wim LeersTrying to only respond to things that have not yet been made irrelevant.
#50:
\Drupal\Core\DependencyInjection\ClassResolver::getInstanceFromDefinition()
explicitly supportsContainerInjectionInterface
. But a consequence of using the class resolver is that each invocation will construct a new instance. So everylayout_builder_entity_view_alter()
invocation during a request (e.g. once for every node in a view listing nodes) will cause a new object to be constructed, and fetch the same dependencies from the container again.🤔 Ahhh! But why are these 3 special? I can understand it forThis is testingtitle
on the canonical page of an entity. I know that forNode
,uid
andcreated
are also special. But not for other entity types, right?Node
, so this makes perfect sense.#53.1: Right,
\Drupal\quickedit\QuickEditController::renderField()
always splits on-
.quickedit.api.php
documents this, but not very clearly 😞 Sorry.#55:
It's cached by entity translation and used view mode (or for custom render pipelines: "Quick Edit view mode"). You have the power to pretend every layout change is a different "Quick Edit view mode". The
data-quickedit-field-id
is what is being looked up insessionStorage
. This may or may not be enough.#56: this is going in the direction that I wrote in response to #55.4 too 👍 But just the
data-quickedit-entity-id
won't be enough, since that doesn't include view mode (because the intent is to ensure multiple occurrences of the same entity on the same page are all updated automatically if you edit one of them, this is the way we match them up IIRC).#59 + #60: I like where this is going! But are you sure that
data-quickedit-field-id
alone isn't enough? Because this first checks if all metadata for thedata-quickedit-field-id
s for a given entity in the DOM of the current page exists:and if not, if fetches that metadata using
fetchMissingMetadata
. I think that should work, and it'd remove the need for the custom JS, as well as thedrupalSettings
stuff, making Layout Builder far less coupled to Quick Edit's implementation details.#61 + #80: there be dragons. That's where it really hurt us that Quick Edit was written in a time where JS testing in Drupal was impossible, JS tests were only added years later :(
#89:
🤔 Is this fixing a bug in HEAD? Do we need separate test coverage for it?
🤔 The caller of
getSectionComponentForFieldName()
doesn't seem to be specific to Quick Edit at all, yet that method does things very specific to Quick Edit. I can't figure out why that is the case.🤔 "formatter settings" versus "component"?
Also, there are no "Quick Edit section components" AFAICT? Does that mean this is actually
getSectionComponentForUseInQuickEdit()
or something like that?🤔 Shouldn't this then do:
? Isn't this currently allowing silent failures?
Nit: s/starts/starts with/
Comment #92
tedbow@Wim Leers thanks for the review.
re #90
#50
#53.1 oh just found this. Nice
#55
Actually want to upload this patch with the current tests so I can make sure it is not just passing because somehow I messed up the test.
We do this after the this patch.
This was not working for me before and that is why I added the Javascript to clear the metadata. I think I found the problem though.
I think wasn't clearing the metadata even when it had new
data-quickedit-field-id
because of #2966136: Quick Edit assumes that all fields meta data are stored in cache or noneBasically if the fields not controller by layout builder, title, uid and created had the same
data-quickedit-field-id
as when layout builder was not used then the new metadata was not fetched.So when a node was viewed and the layout was enabled for the node when the node was viewed again quickedit did not work.
So the solutions for this for this is for Layout Builder alter the
data-quickedit-field-id
for all fields on the entity even if they are not controlled by Layout Builder.This allows removing the javascript from this patch!
This last point from #90 I am going address in this patch will address the rest after this patch passes.
Some other things I changed while figuring this out.
Instead of using drupalSettings with hash of the sections the hash is now being concatenated onto the end of the quickedit view mode.
This means the
data-quickedit-field-id
will change everytime the sections change,which could mean field change in the layout.Also when I moved the logic into this function I switched to hash that actual built sections rather than the section storage sections. This will not work because it will change when the actual field values change.
It makes more sense here to actually just render the entity and then extract the rendered component.
This will also work for field not rendered by the layout builder like title which we have to handle because we altering the
data-quickedit-field-id
for these fields too.Comment #95
tim.plunkettThis goes against a standard pattern used in multiple core modules.
If this is a good change to be made, a follow-up should be opened to make the same change elsewhere.
Comment #96
Wim Leers#92: great step forward!
I just dug into #2966136: Quick Edit assumes that all fields meta data are stored in cache or none and was unable to reproduce it: #2966136-6: Quick Edit assumes that all fields meta data are stored in cache or none
Patch review:
Reviewed that issue too.
👍 LGTM! The hash is updated whenever the layout changes.
Comment #97
tim.plunkettI didn't make any substantive changes to the code here. For the tests, it was mostly reverting things that seemed like debugging changes.
Comment #98
phenaproximaShould we wrap this in a moduleExists('quickedit') check?
Nit: This seems unnecessary. It's not a big deal at all; just a little jarring at first glance, unless you know LayoutEntityHelperTrait.
Why does this code check for ConfigurableInterface? If I'm understanding this correctly, the only block plugin which will work for this method is FieldBlock. Why not simply codify that, and check for an instance of FieldBlock? (In which case we can probably lose the isset($configuration['formatter']) check.)
Classes should call their own methods; can this be
if ($original_mode = $this->getOriginalMode())
instead?Typo: Should be "...to distinguish it..."
"component" should be quoted so that we know that it's a magic string.
It might be useful to add a @see here referencing the relevant code in QuickEditIntegration, and also provide an example of what the original mode string might look like.
Can we use $this->getTargetEntityTypeId()?
So, this will return the first instance of the relevant field block. Discussed with Tim, and he convinced me that this is actually okay behavior. However, I'm wondering if we should maybe add test coverage, assuming we don't already have any, of what happens if the same field is in the layout more than once. Even if it works in manual testing, we might want to have a test of it just to be sure it doesn't regress.
It a bit seems strange to me for this method to call getQuickEditSectionComponent(). Ideally, getComponent() would do something like
$section_component = $this->getQuickEditSectionComponent() ?: $this->getSectionComponentForFieldName($name)
. I think that might make the overall logic a little less magical, and it would also remove a level of nesting from this method.Maybe explode() should be called with PluginBase::DERIVATIVE_SEPARATOR?
"format module name-id" is how this reads. Can it be "...in the format 'module_name-id'"?
It's not clear why this hash is generated. Could probably use a comment...
"IN THIS ISSUE"? Is this dealt with?
I think it would be preferable to return early if $entity is not an instance of FieldableEntityInterface.
Pro-tip: I think that callables can be invoked like
$callable($entity_build)
. No need for call_user_func().I think this could be elseif to remove a level of nesting.
Pro-tip: isset() is variadic, so you can call
isset($component['content']['#field_name'], $component['#base_plugin_id'])
to save a bit of typing.This can just be
return $entity->getFieldDefinition(...)->isDisplayConfigurable('view')
, to remove a level of nesting.Should be protected.
Well, this is pretty interesting. Can the comment expand on why we need this flag? Maybe a couple of @see references?
Empty line. Also, can $array get a better name?
Some of the changes to this class don't seem, on their face at least, to be in scope. Why are we modifying Quick Edit's tests?
Comment #99
tim.plunkett#98
1)
Sure, although this was already protected by a permission check inside entityViewAlter. But can't hurt here.
The other QuickEditIntegration usage is in a quickedit-provided hook, so no need there.
2)
Removing this, because it's _not_ necessary, and it itself uses service location anyway (because it's an Entity class)
3)
It checks for ConfigurableInterface because SectionComponent::getPlugin() doesn't guarantee anything more.
I'd rather leave this than unnecessarily couple it to FieldBlock (which could always be swapped out)
4)
Sure :)
5)
Fixed
6)
Fixed
7)
There is a whole comment directly above this line that explains it and points to the method directly, and there are corresponding @see's on this method itself
8)
Fixed
9)
@todo for testing
10)
Sure, that's fine. Doesn't really matter either way
11)
Yes! Thanks for catching this.
12)
Fixed
13)
Wrote a comment
14)
After investigating more, I think this can be removed.
15)
Fixed
16)
I rewrote this whole part and opened up #3041635: Provide a reliable way to execute #pre_render while still retaining an array
17)
Fixed
18)
True, not a huge win, but changed anyway
19)
Changed
20)
Cannot be changed here because QuickEditJavascriptTestBase and QuickEditIntegrationTest (parent classes) wrongly use
public
21)
Expanded
22)
Changed
23)
There are no actual changes in this class, but certain portions of it are divided into methods that can be overridden in the subclass.
For example,
testArticleNode()
is split intocreateNodeWithTerm()
anddoTestArticle()
Wim clarified in #96 that upstream changes were okay
Assigning to myself to work on #98.9
Comment #100
phenaproximaBy checking for
$configuration['formatter']
, it is already coupled to FieldBlock, though not quite as tightly. As it currently is, the code assumes that any configurable plugin with a "formatter" element in its configuration (even if it's not an array!) is the plugin we want -- and it might or might not be a FieldBlock, which could potentially lead to side effects or errors. So IMHO, since this is already coupled, we can simplify the code around it. One possible option would be to couple it to the plugin ID (using DerivativeInspectionInterface), rather than the concrete implementation. However, if you feel very strongly about this point, I won't push back.Otherwise, interdiff looks full of nice changes. Thanks, Tim!
Comment #101
tedbowre #100
I agree checking 'formatter' here we are assuming no other configurable plugin will use this key for other non field formatter configuration which doesn't seem safe.
checking the check to be
$plugin instanceof DerivativeInspectionInterface && $plugin->getBaseId() === 'field_block'
because that is what are using in
getQuickEditSectionComponent()
Comment #103
tim.plunkettAfter discussion with @dead_arm and then with @tedbow and @phenaproxima, we agreed that the best resolution for #98.9 will be to prevent quickedit when a field is placed multiple times.
Fixing it in any other way would mean a significant refactor of quickedit itself.
I've opened #3041850: Allow Quick Edit to work when a field is placed more than once within the same entity as a follow-up and linked it where relevant.
Removing the CR tag as it was added in #5 when there were API changes being made. It is no longer relevant.
Comment #105
tedbowThe additional change for multiple instances of the same field looks good to me!
Comment #106
phenaproximaUnder what circumstances would hasAttribute() throw an exception?
Comment #107
tedbowre #106
🤔 when I leave debug code in and the debug code is actually very bad because it doesn't actually do what I thought it did?
Removing and adding a couple comments in that method.
Comment #109
tedbow#108 was a random fail.
Comment #110
tedbowTalked to @phenaproxima and pointed out this "will may be" typo.
Also split the comment into 2 sentences because the current sentence has 2 "which..." clauses.
Comment #111
phenaproxima@tim.plunkett and @tedbow were kind enough to get on a Zoom with me and walk me through this patch, nearly line by line.
I think we are all in agreement that this patch is a Slytherin: it's doing all sorts of weird, scary, and questionable magic to achieve its aims. We are also in agreement that this is mostly due to the underlying architectural assumptions upon which Quick Edit is built. It was never designed to work with something like Layout Builder; it assumes that the standard Field API is responsible for all entity rendering, and this assumption is baked into it at every level. Layout Builder explodes (pardon the pun once you read the patch and see the number of calls to
explode()
) a bunch of those assumptions, and therefore it needs to get into areas where, in an ideal world, it wouldn't have to go. Follow-ups are open to improve all of this, but for now, this patch is very much steeped in a (understandable) "do what you gotta do" mentality.The extension of QuickEditIntegrationTest is confusing, but it's also clever. The rationale is to be sure that everything Quick Edit tests, is also tested with Layout Builder enabled. So the idea makes sense, but it necessitated moving a bunch of code around in QuickEditIntegrationTest, which is why that test has such extensive changes in this patch.
Given the facts of how Quick Edit currently works and its limitations, and how important this patch is to Layout Builder's stabilization, I agree with the "do what you must" approach, and I'm RTBCing it.
Comment #113
tim.plunkettThis is from the interdiff from #107
This is where the fail is happening. I had that assert in there and idk why it helped but it did.
Comment #114
Wim LeersI think this is a reasonable compromise for what really is an edge case. Thanks for filing #3041850: Allow Quick Edit to work when a field is placed more than once within the same entity!
✅ s/QuickEdit/Quick Edit/. Fixed.
🤔 How is it possible that we can
explode('-', …)
, get 4 parts, and then againexplode('-', …)
on one of the parts?👎✅ This is restating much of what\Drupal\layout_builder\QuickEditIntegration::entityViewAlter()
is already stating and whathook_quickedit_render_field()
's documentation is prescribing. Fixed.✅ This statement is not entirely accurate. Fixed.
✅ That's a lot of different descriptions for the same thing. Understandable, because it's one of the weirdest things in Quick Edit.
Let's call this
Quick Edit view mode ID
consistently. That'll make it easier to understand, now, and in the future.(Again: yes, this API is weird, I said that 364 days ago in #5 and more recently in #49, grep for "weird".)
Done.
✅ Übernit: third person singular. Fixed.
👏 Very clever! This will most certainly help in future support requests :)
🤔 What does "view configurable fields" mean?
AFAICT this is now dead code. Deleted. 🥳
Only points 2 and 8 need a response, the rest I addressed myself.
Comment #115
Wim LeersComment #116
johnwebdev CreditAttribution: johnwebdev commentedManually testing #115
Installed Layout Builder, Basic page, Override. Created a basic page.
When trying to Quick Edit the Page body, it goes up to the title, see attached image:
Trying to add a new block does not work:
Comment #117
Wim LeersSo only #114.2 is a relatively important question, #114.8 is just a nit. Even #114.2 is not very important as long as the test show it works correctly.
Wearing my Quick Edit maintainer hat, this is RTBC:
hook_quickedit_render_field()
, to use Layout Builder's render pipelineBut unfortunately the latest patch is failing, and if @tim.plunkett is right in #113, then reverting #107's simplification fixes it, but we don't understand yet why that's the case. The concrete failure is:
This is triggered by
\Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderQuickEditTest::getQuickEditFieldId()
reading the value of an attribute of the current page. This exception is thrown by\Drupal\FunctionalJavascriptTests\WebDriverCurlService::execute()
:The code prior to #107 was catching the generic
\Exception
and was therefore gracefully handling this error. Note that this is a curl error, not a HTTP error response. If that were the case, then\WebDriver\AbstractWebDriver::curl()
would've been able to handle it! No, this is a truly a curl error. It seems we'rehitting a bug in the PHP curl webdriver code … and I don't think that should hold this up.
If my analysis is correct, then reverting #107's interdiff but catching a more specific exception would be a fair way to move forward here, to avoid getting blocked on an upstream bug. I don't get why this does work and the code above does not, but us hitting an obscure edge case bug upstream would explain it.
This is just an attempt, if somebody sees a better path forward, I'm all for it!
Comment #120
tim.plunkett#114.2
I think this got broken in a refactoring :(
#114.8
"view configurable" should be "display configurable" and refers to a Field UI concept
#116
This was all broken in a recent reroll. That code ended up in the wrong hook.
The current parent class QuickEditIntegrationTest has random fails in it: #3037436: [random test failure] Make QuickEditIntegrationTest more robust and fail proof
This test should instead extend QuickEditJavascriptTestBase and only contain the first test method, removing the second and third (which are overrides of the parent class).
We should not be testing Quick Edit integration in the Layout Builder UI, only on the rendered entity.
This is now failing as #3002608: Remove contextual links not related to layout administration inside layout builder blocks was committed.
Comment #121
Wim LeersD'oh, OF COURSE!
Comment #122
tim.plunkettThis fixes #115 only (git fuzz context)
Comment #123
tedbowSettings needs review for tests
Comment #124
Wim LeersWrestled with Java, managed to get it installed.
https://www.oracle.com/technetwork/java/javase/downloads/index.html
is a place of nightmares. I'm now able to locally reproduce the test failure. That's progress.Meanwhile, fixed #114.2 & #114.8 per #120.
Comment #125
Wim LeersWith #124, I get these results:
Comment #126
tim.plunkettPHP 7.0 isn't even an option on DrupalCI, but I queued up 5.5, 5.6, 7.1, and 7.3 in addition to the default 7.2
Comment #127
tim.plunkettWait, this should be failing in HEAD now (see #120.2). How did it pass? That is worrisome.
Comment #128
tedbowre #127.
Here
createLayoutOverride()
got to that path and creates a layout override.but it
assertQuickEditInit()
does not test quickEdit on that path because....This is the first line of
assertQuickEditInit()
.We always get the node view page before testing Quick Edit.
Comment #129
Wim Leers@tedbow and I are pair-programming to address #120.
Comment #130
Wim LeersThe results of the pair programming @tedbow and I did: #120.1 & #120.2 addressed, and three explicit test methods:
testEnableDisableLayoutBuilder()
, but now with clearer code (addressing #127), scope and description:Tests Quick Edit boots correctly with Layout Builder defaults & overrides.
testQuickEditIgnoresDuplicateFields()
:Tests that Quick Edit still works even when there are duplicate fields.
— by placing thebody
field twice instead of adding a "datetime" field and placing it twice in the layouttestLayoutBuilderRenderPipelineForQuickEdit()
:Tests that the Layout Builder render pipeline for Quick Edit works.
— by updating thebody
field through Quick Edit and asserting it is re-rendered correctly. It does the minimal set of operations and hence doesn't inherit the brittleness of the Quick Edit JS tests.All of this is much simpler now. Reliably passing locally, #124 failed occasionally locally. Hopefully DrupalCI confirms its stability.
Next steps:
core/modules/quickedit
Comment #131
Wim LeersThis addresses #130.2.
Comment #134
tedbowre #120.1
While I was talking @Wim Leers he said that we can't totally remove the other 2 methods because was not aware that this would basically leave our assertions with
assertQuickEditInit()
which does not cover the render pipeline,\Drupal\layout_builder\QuickEditIntegration::quickEditRenderField()
So @Wim Leers and I worked on the patch that resulted in #130.
This was passing for @Wim Leers locally but failed on DrupalCi. The seems random which is covered by #3032275: Create a fault-tolerant method for interacting with links and fields in Javascript tests. But even if I apply a fix similar to this it still fails randomly for me.
there is another change we have to make for waits that will add next.
I will try to implement the wait fixes I did earlier in the patch but I am still not sure we can avoid the random failure.
Comment #135
Wim LeersMeanwhile, this addresses #130.3. In doing so, I had to update the assertions added in #130 to wait for the appropriate state: for the saving to be completed. Now it's passing consistently :)
Comment #136
Wim LeersAttempt to fix the random failures.
Comment #137
tedbowAdding extra assert waits.
Comment #141
Wim LeersTrying to eliminate one last suspicion.
Comment #143
tedbowonly testing testLayoutBuilderRenderPipelineForQuickEdit
Last attempt
Comment #145
tedbowOk this patch goes patch removing
testLayoutBuilderRenderPipelineForQuickEdit()
because seems impossible and beyond the scope of the issue to make random test failure proof QuickEdit test for Layout builder. In HEAD the\Drupal\Tests\quickedit\FunctionalJavascript\QuickEditIntegrationTest
which is QuickEdit's own tests fail randomly already. So that will need to be fixed in #3037436: [random test failure] Make QuickEditIntegrationTest more robust and fail prooftestEnableDisableLayoutBuilder()
andtestQuickEditIgnoresDuplicateFields()
which should both pass consistently will also upload a patch to prove this.I talked with @xjm, @tim.plunkett and @Wim Leers and we agreed that this best we can for test coverage given the existing random failures in QuickEdit tests.
Comment #146
tedbowWell this is super frustrating.
core-quickedit-x100.patch passed. I ran this exact patch which only has changes to drupalci.yml 3 days ago and failed about 50%. https://www.drupal.org/project/drupal/issues/2977515#comment-13032995
console output: https://dispatcher.drupalci.org/job/drupal_patches/89774/console
so I still stand by #145. When everything is running great on drupalci the random fails don't happen but we shouldn't try to write test coverage for this quickedit functionality until we can get it working always or nearly always with just quick edit itself. which we still can't
UPDATE: retested core-quickedit-x100.patch and now it failed 47 out of 100 times. Yay, I guess. Anys proves it fails pretty randomly
Comment #148
tedbowrequeued #136, #137 #143
to see if they randomly start passing.
Comment #152
Wim LeersCreated that issue for
QuickEditIntegrationTest::testLayoutBuilderRenderPipelineForQuickEdit()
as mentioned in #145: #3042870. Patch on top of #145 at #3042870-2: Follow-up for #2948828: add test coverage for Layout Builder's custom Quick Edit render pipeline once Quick Edit integration tests have been stabilized.Instead of automated testing, we'll need manual testing. I know for a fact this is working correctly, since I wrote this test together with Ted and saw it pass with my very own eyes in an automated Chromium instance before my eyes dozens of times. It's only on DrupalCI that it's failing.
Given that, I think that as the Quick Edit maintainer I can sign off on the Quick Edit aspects of this patch.
Comment #153
larowlanwhat if someone puts the same field in the layout twice...it could happen, things like title or image would be candidates
shouldn't we be doing cacheability stuff here with the permissions miss, eg adding user.permissions context, so that if permissions change this gets another chance? or is that already done by quick edit?
oof this is some nasty stuff...
Comment #154
larowlanI'm not seeing that, so can we update the issue summary with the final result etc
Comment #155
johnwebdev CreditAttribution: johnwebdev commented#153.1 That is a work-around until #3041850: Allow Quick Edit to work when a field is placed more than once within the same entity
Comment #156
Wim Leers#153:
!isset($build['_layout_builder'])
has cacheability added in\Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay::buildMultiple()
(well, by\Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay::buildSections()
which is called by that)user.permissions
is a required cache context, so not necessary in principle. But you're right, that'd the correct thing to do. Especially if in the long run we'd stop relying on required cache contexts. Added that.Comment #157
tim.plunkett#156.2 isn't necessary but it's a good idea either way.
Fixed this IS, there are no API changes here anymore
Comment #158
webchickOk, sorry, but I did find a problem here. (Tested in Chrome 72.0.3626.121 (Official Build) (64-bit) on macOS Mojave, 10.14.3 (18D109) and verified during screenshare with @tim.plunkett.)
When you go into the "local task" Layout tab on a node and make any changes there (e.g. reorder fields, add a new field) and save it, upon returning to the node view, if you click on the Quick Edit contextual link, nothing happens. If you look in JS console, you'll see "Uncaught TypeError: Cannot read property 'offset' of undefined":
Shift+reload works, as does navigating to another page, so Tim suspected the
$sections_hash
stuff perhaps playing a role, although we tried setting that to a static string, and that not only had the same problem, but also the problem that code was originally introduced to fix.Non-layoutable nodes did not exhibit this problem.
Comment #159
tedbowSomehow the changes in #92.4 got removed from the patch.
Basically
Comment #160
tim.plunkettOh, I don't know how we lost that. Yeah, that's super important!
Comment #161
Wim Leerss/view_mode/Quick Edit view mode ID/
s/QuickEdit/Quick Edit/
s/to field metadata/the field metadata/
Let's fix that on commit. (I'm not posting another patch because another core test run will take a long time again. Can also be done in a follow-up of course.)
Comment #162
webchickUpdating credit.
Comment #167
webchickAwesome, that did the trick!
Committed and pushed to 8.8.x and backported to 8.7.x, since it's an experimental module. Thanks!
Comment #169
larowlanRelated follow up #3110232: Layout builder / Quickedit integration breaks if you embed another layout builder view mode in the full page
Comment #170
ventzie CreditAttribution: ventzie commentedIs there a patch for drupal 8.9?